mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Changed scheduled jobs not run immediately after initialization
refs https://github.com/breejs/bree/issues/50
This commit is contained in:
parent
295887dd24
commit
f1ab1597e8
@ -4,7 +4,10 @@ const assemble = (when, job, data, name) => {
|
||||
const breeJob = {
|
||||
name: name,
|
||||
// NOTE: both function and path syntaxes work with 'path' parameter
|
||||
path: job
|
||||
path: job,
|
||||
// NOTE: avoids executing job immidiately after initialization
|
||||
// can remove it when https://github.com/breejs/bree/issues/50 is fixed
|
||||
timeout: false
|
||||
};
|
||||
|
||||
if (data) {
|
||||
|
@ -22,11 +22,11 @@ async function shutdown(signal) {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
jobManager.scheduleJob('every 10 days', path.resolve(__dirname, '../jobs/graceful.js'));
|
||||
jobManager.scheduleJob('every 10 seconds', path.resolve(__dirname, '../jobs/graceful.js'));
|
||||
|
||||
await setTimeoutPromise(100); // allow job to get scheduled
|
||||
|
||||
await pWaitFor(() => Object.keys(jobManager.bree.workers).length === 0);
|
||||
await pWaitFor(() => (Object.keys(jobManager.bree.workers).length === 0) && (Object.keys(jobManager.bree.intervals).length === 0));
|
||||
|
||||
process.exit(0);
|
||||
})();
|
||||
|
@ -100,11 +100,13 @@ describe('Job Manager', function () {
|
||||
|
||||
await delay(1); // let the job execution kick in
|
||||
|
||||
should(Object.keys(jobManager.bree.workers).length).equal(1);
|
||||
should(Object.keys(jobManager.bree.workers).length).equal(0);
|
||||
should(Object.keys(jobManager.bree.timeouts).length).equal(0);
|
||||
should(Object.keys(jobManager.bree.intervals).length).equal(1);
|
||||
|
||||
await jobManager.shutdown();
|
||||
|
||||
should(Object.keys(jobManager.bree.workers).length).equal(0);
|
||||
should(Object.keys(jobManager.bree.intervals).length).equal(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user