acrolink
What is the best way to terminate a Phoenix application having the PID
What is the best way to stop a Pheonix application from within a bash script? I have the PID of the process, how to stop it in a safe manner (i.e. giving it the time it needs to process fully current requests / database transactions)?
Most Liked
bryanhuntesl
You could try integrating this : GitHub - lyokato/the_end: Elixir Library: provides a graceful shutdown support for your Phoenix, or plain Plug application · GitHub
Build a release using distillery
Create a custom handler script - and configure for the release
Then invoke the handler script when you want to achieve a graceful shutdown.
For bonus points you could implement a POSIX signal handler using something like tsutsu/signal_handler - or roll your own - and have it invoke your hander - this would also have the advantage you could just send a kill signal to the Elixir process (in the operating system sense of the word).
bryanhuntesl
Ah that’s much easier - just create a release using distillery (or whatever) and execute it’s stop / start commands - things get weird between the different operating system flavors - and distillery does not just send an OS signal - it actually connects to the node and invokes a purpose built shut-down command -
bryanhuntesl
Here’s the top level implementation of what it does - i.e. it does all that stuff - then finally invokes the OS level kill - distillery/priv/libexec/commands/stop.sh at b945641ebbc17848378f4cd0f1c116ec78326ad4 · bitwalker/distillery · GitHub
Really building releases is the way to go
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









