-
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
Capture SIGINT, SIGTERM, SIGQUIT signals from terminal in both iCubTelemVizServer and openmctStaticServer and close the later #38
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…parately to each node.js process - Sending <CTRL+C> to the main process stdin ('iCubTelemVizServer') is propagated to the 'openmctStaticServer' process. - Sending any of the three events through the command 'kill' is not propagated from 'iCubTelemVizServer' to 'openmctStaticServer'. Kill has to be sent separately to each process.
…mct child process - The previously returned 'ChildProcess' object was the 'npm' process. - This only allowed killing the child process through CTRL+C input (that stdin string would then generate the SIGINT event which would then be propagated to the child processes npm start -> sh -c ". ${NVM_DIR}/nvm.sh; nvm use v14.17.0; node server.js" -> node server.js - Sending a SIGQUIT, SIGTERM or SIGINT from terminal though 'kill -s...' to the 'npm start' process, parent of the node.js process wouldn't kill the later, and there was no direct way to retrieve the node.js process pid programmatically. - We should retrieve the PID information directly from the child node.js process through an IPC channel between child and parent node.js processes. - For this we add a 4rd stdio entry for the spawned command: 'spawn(...,{..., stdio: ['pipe','pipe','pipe','ipc']})'. - We send the node.js child process PID to the parent process via the created IPC channel. - We have to spawn a 'sh runModule.sh' command instead of the 'npm start' as npm does not propagate the IPC channel either. - The sh script 'runModule.sh' holds the same commands as the npm script used to. Now both node.js processes can be killed through 'kill -s...' command or through the 'CTRL+C' input.
nunoguedelha
force-pushed
the
fix/servers-closure
branch
from
October 13, 2021 23:56
ad02d5f
to
a044f2b
Compare
3 tasks
- Check if IPC channel is available from the Node.js child process before using it, otherwise we get an error (undefined 'process.send()') when we run 'openmctStaticServer' module as a standalone process. - Track all opened connections in 'openmctStaticServer' module. - Close the server (stop it from accepting new connections) and close any connections remained open.
Testing the changes
In this example, battery status and the fake framegrabber are not running nor connected.
These connections are created for retrieving the signal JSON dictionary every time you click on a telemetry entry (this behaviour could be improved later).
Stopping the application with SIGINT or by typing |
nunoguedelha
changed the title
Close the servers properly when interrupting from the terminal via SIGINT (CTRL+C) or SIGTERM signals
Capture SIGINT, SIGTERM, SIGQUIT signals from terminal in both iCubTelemVizServer and openmctStaticServer and close the later
Oct 14, 2021
S-Dafarra
reviewed
Oct 14, 2021
iCubTelemVizServer/.idea/runConfigurations/iCubTelemServerStart_DEBUG.xml
Show resolved
Hide resolved
S-Dafarra
approved these changes
Oct 20, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #41 .
Fixes #42 .