Add shutdown tasks and fix signal forwarding#511
Open
Nolah2 wants to merge 1 commit intoCyferShepard:unstablefrom
Open
Add shutdown tasks and fix signal forwarding#511Nolah2 wants to merge 1 commit intoCyferShepard:unstablefrom
Nolah2 wants to merge 1 commit intoCyferShepard:unstablefrom
Conversation
Fix signal forwarding in the Dockerfile and entry.sh script. Implement sigterm/sigint handlers in the app with shutdown tasks for each service.
2cebec0 to
2e1c04c
Compare
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.
When shutting down the containers, signals are not being properly forwarded from the script/npm to node. This results in a slow shutdown time. The fix for this is to modify the entry.sh file and use exec so that it doesn't eat PID 1. See here for best practices on achieving this.
Some node images also run into issues with forwarding these signals to child processes, most often being debian. The builder and base image should be replaced with alpine3.23 distro as it does not encounter these issues. See npm/cli#6684 for discussion on this.
Proper shutdown functions should be implemented to close out all websocket connections and shut down the websocket, http, and knex servers/clients.
For transparency, I am pretty new to the node ecosystem (and to some extent, js as a whole) so I did reference an LLM at some points for direction. All code was loosely based on existing FOSS projects or stackoverflow posts.