33 lines
789 B
JavaScript
33 lines
789 B
JavaScript
|
/* eslint-disable no-console */
|
||
|
|
||
|
const pWaitFor = require('p-wait-for');
|
||
|
const path = require('path');
|
||
|
const setTimeoutPromise = require('util').promisify(setTimeout);
|
||
|
const JobManager = require('../../lib/job-manager');
|
||
|
|
||
|
const jobManager = new JobManager({
|
||
|
info: console.log,
|
||
|
warn: console.log,
|
||
|
error: console.log
|
||
|
});
|
||
|
|
||
|
process.on('SIGINT', () => {
|
||
|
shutdown('SIGINT');
|
||
|
});
|
||
|
|
||
|
async function shutdown(signal) {
|
||
|
console.log(`shutting down via: ${signal}`);
|
||
|
|
||
|
await jobManager.shutdown();
|
||
|
}
|
||
|
|
||
|
(async () => {
|
||
|
jobManager.scheduleJob('every 10 days', path.resolve(__dirname, '../jobs/graceful.js'));
|
||
|
|
||
|
await setTimeoutPromise(100); // allow job to get scheduled
|
||
|
|
||
|
await pWaitFor(() => Object.keys(jobManager.bree.workers).length === 0);
|
||
|
|
||
|
process.exit(0);
|
||
|
})();
|