forked from OpenTermsArchive/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedule.js
29 lines (22 loc) · 850 Bytes
/
schedule.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import schedule from 'node-schedule';
import Notifier from './src/notifier/index.js';
import CGUs from './src/index.js';
(async () => {
try {
const rule = new schedule.RecurrenceRule();
rule.minute = 30; // at minute 30 past every hour.
console.log('The scheduler is running…');
console.log('Documents will be tracked at minute 30 past every hour.');
const app = new CGUs();
await app.init();
const notifier = new Notifier(app.serviceDeclarations, app.documentTypes);
app.on('versionRecorded', notifier.onVersionRecorded.bind(notifier));
app.on('fetchingError', notifier.onDocumentFetchError.bind(notifier));
app.on('error', notifier.onApplicationError.bind(notifier));
schedule.scheduleJob(rule, () => {
app.trackChanges();
});
} catch (error) {
console.error(error);
}
})();