video-optimizer-bot / src /queue /shutdown.js
Hugging Face Deployer
Deploy bot to Hugging Face Spaces
03b405b
Raw History Blame Contribute Delete
416 Bytes
function registerGracefulShutdown(queue, logger) {
let shuttingDown = false;
async function stop(signal) {
if (shuttingDown) return;
shuttingDown = true;
logger.info({ signal }, "Graceful shutdown started");
queue.pause();
await queue.waitForIdle(30_000);
process.exit(0);
}
process.on("SIGINT", stop);
process.on("SIGTERM", stop);
}
module.exports = { registerGracefulShutdown };