Handle SIGHUP gracefully

Invoke shutdown instead of exiting immediately when SIGHUP is received,
and do the same on both slave and master for signals received.
This commit is contained in:
Hornwitser committed 2021-02-17 17:49:54 +01:00
1 parent 4ca092f351
commit 9660fa0801
2 files changed
+7 -7

No files matched your search

+2 -6
View File
@@ -1985,13 +1985,9 @@ async function startServer(args) {
logger.info("Caught termination signal, shutting down");
shutdown();
});
// terminal closed
process.on("SIGHUP", () => {
// No graceful cleanup, no warning out (stdout is likely closed.)
// Don't close the terminal with the clusterio master in it.
// eslint-disable-next-line no-process-exit
process.exit(1);
logger.info("Terminal closed, shutting down");
shutdown();
});
await fs.ensureDir(masterConfig.get("master.database_directory"));
+5 -1
View File
@@ -1633,7 +1633,7 @@ async function startSlave() {
process.on("SIGTERM", () => {
if (secondSigterm) {
setBlocking(true);
logger.fatal("Caught second termination signal, terminating immediately");
logger.fatal("Caught second termination, terminating immediately");
// eslint-disable-next-line no-process-exit
process.exit(1);
}
@@ -1642,6 +1642,10 @@ async function startSlave() {
logger.info("Caught termination signal, shutting down");
slave.shutdown();
});
process.on("SIGHUP", () => {
logger.info("Terminal closed, shutting down");
slave.shutdown();
});
slaveConnector.once("connect", () => {
logger.add(new libLoggingUtils.LinkTransport({ link: slave }));