Handle SIGINT a bit more gracefully - disconnect clients
This commit is contained in:
parent
36cd4a0d30
commit
bd4c50fa8d
11
core/bbs.js
11
core/bbs.js
|
@ -106,10 +106,15 @@ function initialize(cb) {
|
||||||
logger.init();
|
logger.init();
|
||||||
|
|
||||||
process.on('SIGINT', function onSigInt() {
|
process.on('SIGINT', function onSigInt() {
|
||||||
// :TODO: for any client in |clientConnections|, if 'ready', send a "Server Disconnecting" + semi-gracefull hangup
|
logger.log.info('Process interrupted, shutting down...');
|
||||||
// e.g. client.disconnectNow()
|
|
||||||
|
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();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue