Skip to content

Commit

Permalink
Close Telemetry Server: subset A, step A.2 & A.3
Browse files Browse the repository at this point in the history
- 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.
- Fix console log messages on Open-MCT Static Server closure.
  • Loading branch information
nunoguedelha committed Oct 25, 2021
1 parent dabe06f commit 3776407
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 23 additions & 1 deletion iCubTelemVizServer/iCubTelemVizServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
},
Expand Down
3 changes: 2 additions & 1 deletion openmctStaticServer/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3776407

Please sign in to comment.