rfcx / rfcx-api

Core, Media/Assets and MQTT APIs
https://api.rfcx.org/docs/
Apache License 2.0
0 stars 0 forks source link

feat sigterm-safe deployment (#619) #620

Closed veckatimest closed 5 months ago

veckatimest commented 5 months ago

βœ… DoD

(use na when API docs (Release notes, etc) do not need to be updated)

πŸ“ Summary

This change main part is the deployment.yaml

WHY: when deployment has only args, and no "command", then the command is "bash -c". So inside the pod we have something like "bash -c yarn start:core"

When kubernetes wants to gracefully stop the pod, it sends SIGTERM signal to the main process. But signal does not come into the node.js, it just terminates the bash command. So if we call "node path/file.js" then the main process is the node.js, and it can handle the SIGTERM.

I have tested it. After this change, logs got new messages regarding "Received signal...". And I have also tested that now after sigterm I receive started request. (And that the pod can finish it's busyness).

πŸ›‘ Problems

πŸ’‘ More ideas

Write any more ideas you have

antonyharfield commented 5 months ago

Super!

antonyharfield commented 5 months ago

You could have changed it one time in the Dockerfile and then removed the command/args from the Kubernetes files. https://github.com/rfcx/rfcx-api/blob/6f71d67a15a0056b4b42428f47a36aacbcff0d94/build/Dockerfile#L33