Handle SIGINT a bit more gracefully - disconnect clients

This commit is contained in:
Bryan Ashby 2015-12-11 13:57:56 -07:00
parent 36cd4a0d30
commit bd4c50fa8d
1 changed files with 9 additions and 4 deletions

View File

@ -106,10 +106,15 @@ function initialize(cb) {
logger.init();
process.on('SIGINT', function onSigInt() {
// :TODO: for any client in |clientConnections|, if 'ready', send a "Server Disconnecting" + semi-gracefull hangup
// e.g. client.disconnectNow()
logger.log.info('Process interrupted, shutting down...');
var activeConnections = clientConns.getActiveConnections();
var i = activeConnections.length;
while(i--) {
activeConnections[i].term.write('\n\nServer is shutting down NOW! Disconnecting...\n\n');
clientConns.removeClient(activeConnections[i]);
}
logger.log.info('Process interrupted, shutting down');
process.exit();
});