diff --git a/iCubTelemVizServer/iCubTelemVizServer.js b/iCubTelemVizServer/iCubTelemVizServer.js index 05d7234..31c372b 100644 --- a/iCubTelemVizServer/iCubTelemVizServer.js +++ b/iCubTelemVizServer/iCubTelemVizServer.js @@ -181,12 +181,34 @@ function handleTermination(signal) { /* * === Closure subset A === * A.1 - Stop the child Node.js process running the OpenMCT static server. + * A.2 - Stop the Telemetry HTTP server telemServer from accepting new connections. + * A.3 - Stop the Control Console HTTP server consoleServer from accepting new connections. */ const closeChildProcessPromise = new Promise(function(resolve,reject) { ret = openMctServerHandler.stop(signal,resolve,reject); console.log(ret); }); - Promise.all([closeChildProcessPromise]).then( + const closeTelemServerPromise = new Promise(function(resolve,reject) { + telemServer.close((error) => { + if (error === undefined) { + resolve('iCub Telemetry Server closed: all sockets closed.'); + } else { + reject(error); + } + }); + console.log('iCub Telemetry Server closing: no further connection requests accepted.'); + }); + const closeConsoleServerPromise = new Promise(function(resolve,reject) { + consoleServer.close((error) => { + if (error === undefined) { + resolve('Control Console Server closed: all sockets closed.'); + } else { + reject(error); + } + }); + console.log('Control Console Server closing: no further incoming requests accepted.'); + }); + Promise.all([closeChildProcessPromise,closeTelemServerPromise,closeConsoleServerPromise]).then( function(values) { values.forEach((v) => console.log(v)); }, diff --git a/openmctStaticServer/server.js b/openmctStaticServer/server.js index 7de215f..444eaa5 100644 --- a/openmctStaticServer/server.js +++ b/openmctStaticServer/server.js @@ -31,11 +31,12 @@ SignalName2codeMap = require('../common/utils').SignalName2codeMap; function handleTermination(signal) { console.log('Received '+signal+' ...'); vizServer.close(() => { - console.log('Open-MCT Visualizer Server closed. No further requests accepted. Refreshing the visualizer web page will fail.'); + console.log('Open-MCT Visualizer Server closed: all sockets closed.'); process.exitCode = 128+SignalName2codeMap[signal]; process.removeListener('SIGINT', inhibit2ndSIGINT); // Remove the idle listener clearTimeout(handleTermination.prototype.sigintTimer); // Cancel the timeout that would remove the idle listener }); + console.log('Open-MCT Visualizer Server closing: no further incoming requests accepted. Refreshing the visualizer web page will fail.'); vizServerTracker.closeAll(); // Run a timer for scheduling the removal of the idle listener in case the server closure gets stuck handleTermination.prototype.sigintTimer = setTimeout(function () {process.removeListener('SIGINT', inhibit2ndSIGINT);},5000);