remove statuspagemodule
This commit is contained in:
1 parent
995ae5252d
commit
6b89db131d
4 files changed
+6
-310
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { InitializedServices } from "./config/services.js";
|
||||
import { logger } from "./utils/logger.js";
|
||||
|
||||
export const initShutdownListener = (server: any, services: InitializedServices) => {
|
||||
const SERVICE_NAME = "Server";
|
||||
|
||||
let isShuttingDown = false;
|
||||
|
||||
const shutdown = async () => {
|
||||
if (isShuttingDown) {
|
||||
return;
|
||||
}
|
||||
isShuttingDown = true;
|
||||
logger.info({ message: "Attempting graceful shutdown" });
|
||||
|
||||
try {
|
||||
server.close();
|
||||
await services.jobQueue.shutdown();
|
||||
await services.db.disconnect();
|
||||
logger.info({ message: "Graceful shutdown complete" });
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
const err = error as Error;
|
||||
logger.error({
|
||||
message: err.message,
|
||||
service: SERVICE_NAME,
|
||||
method: "shutdown",
|
||||
stack: err.stack,
|
||||
});
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
process.on("SIGUSR2", shutdown);
|
||||
process.on("SIGINT", shutdown);
|
||||
process.on("SIGTERM", shutdown);
|
||||
};
|
||||
Reference in new issue
Block a user