-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process SIGINT, SIGTERM, SIGQUIT signal events for iCubTelemVizServer Node.js process. #40
Comments
ReferencesReferences on Node.jsReferences on Express and Express-ws, routing etc |
General ApproachWe group the actions in subsets. When a subset A has to be completed before the process exits or before a subset B starts, we use the A promise is a JavaScript object that contains producing code (takes time to execute) and calls (asynchronously) consuming code once the producing code is complete: in our case, the subset A is the producing code and the subset B is the consuming one. If the tasks in the subset A can run in parallel, we can use the
A.1 - Stop the child Node.js process running the OpenMCT static server. The pattern...function subsetA () {
const A1 = new Promise(functionA1(resolve,reject) {
if (<condition>) {
<processing after success>;
resolve(values);
} else {
<processing after failure>;
reject(error);
}
});
const A2 = new Promise(functionA2(resolve,reject) {
if (<condition>) {
<processing after success>;
resolve(values);
} else {
<processing after failure>;
reject(error);
}
});
Promise.all([A1,A2]).then(
<resolve definition: call subsetB()>,
<reject definition>
);
}
function subsetB () {
<same pattern as subsetA>;
} |
First subset A1, A2, A3A.1 - Stop the child Node.js process running the OpenMCT static server. (We added already A.3 as it obviously will be in the first subset) A.1 Stop the child Node.js process running the OpenMCT static serverA.2 & A.3 Stop the HTTP servers from accepting new connectionsIn the same Promise/Resolve cycle, close the servers.
|
B - Stop listening to client requests ("subscribe"/"unsubscribe" events) on the existing connectionsUsed Indeed,
The actual core implementation of pause is probably somewhere deep into
=> #52 Moved to #53 . |
Note
|
Processing the SIGINT event: closeServers(signal) function
The function
closeServers(signal)
implements the following ordered sequence of closure actions:telemServer
from accepting new connections from the still running client web page.consoleServer
from accepting new connections.portInConfig
(turn off the respective listeners).Complete the unfinished processing or responses to the pending requests. => use "drain"Closure Subset D #55non-ticked points just need to be integrated into the Promise/resolve pattern.
consoleServer
from accepting new RPC commands from the control console web client.process.exit()
.Originally posted by @nunoguedelha in #34 (comment)
The text was updated successfully, but these errors were encountered: