Skip to content

Commit

Permalink
After the server closure is complete, cancel the timer that would rem…
Browse files Browse the repository at this point in the history
…ove the idle listener
  • Loading branch information
nunoguedelha committed Oct 20, 2021
1 parent 78f5442 commit 75b6fe8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions openmctStaticServer/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ function handleTermination(signal) {
vizServer.close(() => {
console.log('Open-MCT Visualizer Server closed. No further requests accepted. Refreshing the visualizer web page will fail.);
process.exitCode = 128+SignalName2codeMap[signal];
// Remove the 2nd SIGINT inhibitor listener
process.listeners('SIGINT').forEach((value) => {console.log('listener: %s',value.toString())});
process.removeListener('SIGINT', inhibit2ndSIGINT);
process.listeners('SIGINT').forEach((value) => {console.log('listener: %s',value.toString())});
process.removeListener('SIGINT', inhibit2ndSIGINT); // Remove the idle listener
clearTimeout(handleTermination.prototype.sigintTimer); // Cancel the timeout that would remove the idle listener
});
vizServerTracker.closeAll();
setTimeout(function () {process.removeListener('SIGINT', inhibit2ndSIGINT);},5000);
// 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);
}

// IDLE termination handler for inhibiting an eventual 2nd SIGINT (probably from the parent process)
Expand Down

0 comments on commit 75b6fe8

Please sign in to comment.