1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Try to ensure TCP node closes server connections on redeploy

(to clean up properly - especially in case of port changes)

Closes Issue #454
This commit is contained in:
Dave C-J 2014-10-25 17:52:24 +01:00
parent d9363f4974
commit 0bb78ae491

View File

@ -182,8 +182,11 @@ module.exports = function(RED) {
node.error('unable to listen on port '+node.port+' : '+err);
} else {
node.log('listening on port '+node.port);
node.on('close', function() {
for (var c in connectionPool) {
connectionPool[c].end();
connectionPool[c].unref();
}
node.closing = true;
server.close();
node.log('stopped listening on port '+node.port);
@ -334,6 +337,10 @@ module.exports = function(RED) {
} else {
node.log('listening on port '+node.port);
node.on('close', function() {
for (var c in connectedSockets) {
connectedSockets[c].end();
connectedSockets[c].unref();
}
server.close();
node.log('stopped listening on port '+node.port);
});