Hello, this is partially an Elixir question (and please forgive me for my ignorance) and partially (I believe) a question particularly relevant to how this library is structured.
tl;dr: I'm looking for guidance on the best way to take a SIGTERM or System.stop() and
- toggle
disable_fetch config setting from false to true, live.
- allow currently busy
FaktoryWorker.Job processes to finish their work
- shutdown the
FaktoryWorker supervisor
in that general order.
Long version:
I run a Faktory client on Kubernetes and perform rolling updates where a new pod/container spins up and then Kubernetes sends a SIGTERM to the old pod/container telling it to shutdown.
My goal is to have the old container gracefully finish in-flight jobs before shutting down. My jobs involve transferring large amounts of data. Arbitrarily killing/restarting during deploys can cause downstream problems (resumable streams are not always an option).
Excluding all of the Kubernetes configs to make graceful, rolling deployments happen, I'd like to know how to take a SIGTERM to my Elixir application and in turn disable the fetching of new jobs from Faktory, as well as trap the kill message in my FaktoryWorker.Job processes to give them enough time to finish.
All the examples I've found online for doing this relate to simple GenServers and I'm not positive how to translate them to this library.
For context:
This video shows my desired outcome, but for HTTP requests and GenServers. https://www.youtube.com/watch?v=cbCgB9F6RrM
This forum posts talks about trapping exit messages, but I think this library hardcodes a :brutal_kill signal, which wouldn't work? https://elixirforum.com/t/graceful-shutdown-on-sigterm/23780/2
Any and all help is appreciated!
Hello, this is partially an Elixir question (and please forgive me for my ignorance) and partially (I believe) a question particularly relevant to how this library is structured.
tl;dr: I'm looking for guidance on the best way to take a SIGTERM or
System.stop()anddisable_fetchconfig setting fromfalsetotrue, live.FaktoryWorker.Jobprocesses to finish their workFaktoryWorkersupervisorin that general order.
Long version:
I run a Faktory client on Kubernetes and perform rolling updates where a new pod/container spins up and then Kubernetes sends a SIGTERM to the old pod/container telling it to shutdown.
My goal is to have the old container gracefully finish in-flight jobs before shutting down. My jobs involve transferring large amounts of data. Arbitrarily killing/restarting during deploys can cause downstream problems (resumable streams are not always an option).
Excluding all of the Kubernetes configs to make graceful, rolling deployments happen, I'd like to know how to take a SIGTERM to my Elixir application and in turn disable the fetching of new jobs from Faktory, as well as trap the kill message in my
FaktoryWorker.Jobprocesses to give them enough time to finish.All the examples I've found online for doing this relate to simple GenServers and I'm not positive how to translate them to this library.
For context:
This video shows my desired outcome, but for HTTP requests and GenServers. https://www.youtube.com/watch?v=cbCgB9F6RrM
This forum posts talks about trapping exit messages, but I think this library hardcodes a
:brutal_killsignal, which wouldn't work? https://elixirforum.com/t/graceful-shutdown-on-sigterm/23780/2Any and all help is appreciated!