ami-iit / yarp-openmct

Repo for YARP and OpenMCT integration.
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

Exit the main process after all closure steps are completed #61

Closed nunoguedelha closed 2 years ago

nunoguedelha commented 2 years ago

The Two Main Issues Addressed Here

References

Event Loop https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout https://nodejs.dev/learn/the-nodejs-event-loop https://nodejs.dev/learn/understanding-process-nexttick https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop

Avoiding a Premature Exit

Workaround

Further Analysis

nunoguedelha commented 2 years ago

Closing all the ports manually, and checking the pending handles and requests in the Event Loop :hourglass:

=> Moved to #76

nunoguedelha commented 2 years ago

Avoiding a Premature Exit

Before even adding the listener to the a given closure signal (SIGINT, etc), we execute the following a the end of the main script:

After completing terminationHandler, so, after Subset C... https://github.com/ami-iit/yarp-openmct/blob/b07deb537ee3513b16bd3a14115c469449d38ba9/iCubTelemVizServer/terminationHandler.js#L22-L27

...do: