mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Add SIGTERM handler
This commit is contained in:
parent
2aea6f4456
commit
a4898bc197
@ -131,6 +131,15 @@ export class Server {
|
|||||||
this.server.listen(Config.Server.port, Config.Server.host);
|
this.server.listen(Config.Server.port, Config.Server.host);
|
||||||
this.server.on('error', this.onError);
|
this.server.on('error', this.onError);
|
||||||
this.server.on('listening', this.onListening);
|
this.server.on('listening', this.onListening);
|
||||||
|
this.server.on('close', this.onClose);
|
||||||
|
|
||||||
|
// Sigterm handler
|
||||||
|
process.on('SIGTERM', () => {
|
||||||
|
Logger.info(LOG_TAG, 'SIGTERM signal received');
|
||||||
|
this.server.close(() => {
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.onStarted.trigger();
|
this.onStarted.trigger();
|
||||||
}
|
}
|
||||||
@ -170,6 +179,13 @@ export class Server {
|
|||||||
typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
|
typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
|
||||||
Logger.info(LOG_TAG, 'Listening on ' + bind);
|
Logger.info(LOG_TAG, 'Listening on ' + bind);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener for HTTP server "close" event.
|
||||||
|
*/
|
||||||
|
private onClose = () => {
|
||||||
|
Logger.info(LOG_TAG, 'Closed http server');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user