-
Notifications
You must be signed in to change notification settings - Fork 0
/
cron.js
42 lines (23 loc) · 732 Bytes
/
cron.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
30
31
32
33
34
35
36
37
38
39
40
41
42
const Config = require("./config");
const exec = require("child_process").execFile;
const cron = require("node-cron");
function cronService() {
return new Promise((resolve, reject) => {
exec(Config.knimePath,
Config.params, (error, data) => {
if (error) {
reject(new Error(`Error - ${error}`));
}
resolve(data);
}
);
});
}
cron.schedule(Config.cronTime, () => {
console.log(`running a task every ${Config.cronTime}minute:${new Date()}`);
cronService().then(response => {
console.log (`OK: ${response}`)
}).catch (error => {
console.log (`Error: ${error}`);
});
});