1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Merge pull request #663 from Rickkwa/issue-662

Add SIGTERM handler
This commit is contained in:
Patrik J. Braun 2023-05-21 17:32:01 +02:00 committed by GitHub
commit e204d1d4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,6 +131,15 @@ export class Server {
this.server.listen(Config.Server.port, Config.Server.host);
this.server.on('error', this.onError);
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();
}
@ -170,6 +179,13 @@ export class Server {
typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
Logger.info(LOG_TAG, 'Listening on ' + bind);
};
/**
* Event listener for HTTP server "close" event.
*/
private onClose = () => {
Logger.info(LOG_TAG, 'Closed http server');
};
}