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 };