feat: avoid double SIGINT crashing
This commit is contained in:
parent
eaa8db4b19
commit
9cd7d79b64
|
@ -103,7 +103,12 @@ wsq.process(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let shuttingDown = false;
|
||||||
|
|
||||||
process.on("SIGINT", async () => {
|
process.on("SIGINT", async () => {
|
||||||
|
if (shuttingDown) return;
|
||||||
|
shuttingDown = true;
|
||||||
|
|
||||||
console.log("Gracefully shutting down...");
|
console.log("Gracefully shutting down...");
|
||||||
|
|
||||||
await wsq.pause(true, true);
|
await wsq.pause(true, true);
|
||||||
|
@ -112,8 +117,6 @@ process.on("SIGINT", async () => {
|
||||||
const jobs = await Promise.all(myJobs.map(x => wsq.getJob(x)));
|
const jobs = await Promise.all(myJobs.map(x => wsq.getJob(x)));
|
||||||
console.log("Removing", jobs.length, "jobs...");
|
console.log("Removing", jobs.length, "jobs...");
|
||||||
await Promise.all(jobs.map(async x => {
|
await Promise.all(jobs.map(async x => {
|
||||||
// await wsq.client.del(await x.lockKey());
|
|
||||||
// await x.takeLock();
|
|
||||||
await x.moveToFailed({ message: "interrupted" });
|
await x.moveToFailed({ message: "interrupted" });
|
||||||
await x.remove();
|
await x.remove();
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue