fix: Add timeout to plugin stop requests, correctly propagate termination signals during graceful shutdown#131
Open
TheCrazyGM wants to merge 2 commits intohive-engine:qafrom
Open
fix: Add timeout to plugin stop requests, correctly propagate termination signals during graceful shutdown#131TheCrazyGM wants to merge 2 commits intohive-engine:qafrom
TheCrazyGM wants to merge 2 commits intohive-engine:qafrom
Conversation
…tion signals during graceful shutdown
Author
|
After a few more tests, I believe 2 seconds is a bit harsh, should probably be increased for a bit more timeout. |
This file contains hidden or 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
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.
Description
I run the node as a systemd service and I noticed it always timed out waiting for shutdown or restart. So I looked into it.
The current signal handling logic in app.js is flawed. It catches
SIGINT/SIGTERM, performs cleanup, and then re-sends the signal to the process usingprocess.kill(process.pid, signal). However, since the custom signal handler is still active, it catches the re-sent signal, checks theshuttingDownflag (which is now true), and simply returns, leaving the process running indefinitely.Additionally, I found that during cleanup, some plugins (like P2P or Streamer) might not respond to the IPC message if they are in a bad state, causing
unloadPluginto hang indefinitely while awaiting the response.Changes
stopApp, explicitly remove theSIGINT/SIGTERMlisteners before re-sending the signal. This ensures the default signal handler takes over and terminates the process correctly.unloadPluginfunction. If a plugin does not acknowledge the stop request within 2 seconds, the main process logs an error and force-kills the plugin, preventing the entire shutdown process from hanging.Verification
SIGINT.