-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.js
More file actions
36 lines (26 loc) · 814 Bytes
/
Copy pathclock.js
File metadata and controls
36 lines (26 loc) · 814 Bytes
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
const CronJob = require('cron').CronJob;
const { fork } = require('child_process');
function emailCustomer() {
const job = new CronJob(
'0 10 * * 1', // cron job runs at 10:00am every monday,
async () => await fetchPhoneRecordInNewProcess(),
null,
true,
'Africa/Lagos',
);
job.start();
}
function fetchPhoneRecordInNewProcess(){
const childProcess = fork("./clock_worker.js")
childProcess.send("fetchPhoneRecordInNewProcess")
childProcess.on("error", (err)=>{
console.log("error creating child process", err)
})
childProcess.on("exit", (code, signal)=>{
reject(new Error(`sendReportMail Worker has stopped. Code:${code}, Signal:${signal}`));
})
}
const main = ()=>{
emailCustomer();
}
module.exports = main;