-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcertbotrenew.js
31 lines (27 loc) · 967 Bytes
/
certbotrenew.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
var CronJob = require('cron').CronJob;
var certbotProc;
var spawn = require('child_process').spawn;
module.exports = function () {
var certbotRenew = new CronJob(
'00 45 7 * * 0',
() => {
console.log(new Date(), 'running cert renew');
if (certbotProc) certbotProc.kill();
certbotProc = spawn('certbot', ['renew']);
certbotProc.stdout.on('data', data => {
console.log(`Certbot info: ${data}`);
});
certbotProc.stderr.on('data', data => {
console.error(`Certbot error: ${data}`);
});
certbotProc.on('close', code => {
console.log(`Certbot process exited with code ${code}`);
});
},
() => {
/* This function is executed when the job stops */
},
true /* Start the job right now */,
'America/Chicago'
);
};