jaimeiniesta
Idiomatic way to restart a Phoenix app from inside?
I have a Phoenix app running in Heroku and using Oban for background jobs. I still don’t know why but it can happen that Oban gets stuck and doesn’t pick any job - happily, restarting the app with heroku restart fixes this problem… until it happens again of course.
So, as a temporary measure until we catch the bug, I’d sleep better if I could monitor the app for stuck jobs and in that case, automatically restart the server.
I can do that using the Heroku API but I wonder if there’s an idiomatic way to restart an Elixir / Phoenix app from inside. Is there one?
Most Liked
joaoevangelista
Don’t know much about Oban, but you could send a message to the main supervisor or queue process specially if they have a known name, using Process.exit/2 this will probably force a restart of the process without taking your system down for a restart.
To check if the queue need a restart you could use a simple genserver with periodically checking the queue the same way you do to know it is stuck then issuing the exit.
Hope this gives some light.
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









