mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Merge pull request #357 from furgin/handle-term-signal
Add SIGTERM handler to master and slave.
This commit is contained in:
2 files changed
+25
No files matched your search
@@ -1966,6 +1966,18 @@ async function startServer(args) {
|
||||
logger.info("Caught interrupt signal, shutting down");
|
||||
shutdown();
|
||||
});
|
||||
let secondSigterm = false;
|
||||
process.on("SIGTERM", () => {
|
||||
if (secondSigterm) {
|
||||
logger.fatal("Caught second termination, terminating immediately");
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
secondSigterm = true;
|
||||
logger.info("Caught termination signal, shutting down");
|
||||
shutdown();
|
||||
});
|
||||
|
||||
// terminal closed
|
||||
process.on("SIGHUP", () => {
|
||||
|
||||
@@ -1625,6 +1625,19 @@ async function startSlave() {
|
||||
logger.info("Caught interrupt signal, shutting down");
|
||||
slave.shutdown();
|
||||
});
|
||||
let secondSigterm = false;
|
||||
process.on("SIGTERM", () => {
|
||||
if (secondSigterm) {
|
||||
setBlocking(true);
|
||||
logger.fatal("Caught second termination signal, terminating immediately");
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
secondSigterm = true;
|
||||
logger.info("Caught termination signal, shutting down");
|
||||
slave.shutdown();
|
||||
});
|
||||
|
||||
slaveConnector.once("connect", () => {
|
||||
logger.add(new libLoggingUtils.LinkTransport({ link: slave }));
|
||||
|
||||
Reference in new issue
Block a user