MMore
Run only one instance of Oban
I have an Elixir apps which does some harder jobs in the background. I am using Oban to run them asynchrously. For better availability I’d like to spawn a second server instance of my Elixir app (I am using fly.io) but without spawing another Oban app there.
Currently Oban is just part of the Standard Application Supervision Tree:
def start(_type, _args) do
children = [
# Start the Ecto repository
MyApp.Repo,
MyAppWeb.Telemetry,
{Phoenix.PubSub, name: MyApp.PubSub},
MyAppWeb.Endpoint,
{Oban, Application.fetch_env!(:my_app, Oban)}
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
Any idea how to do it?
Most Liked
engineeringdept
You might also consider using Highlander to ensure a process only runs once, globally, in a cluster. I use it for Quantum cron jobs.
entone
MMore
I guess it can. But I have like jobs which need a lot of processing power. So I don’t wanna let them run on my web facing machine which has less power.
Last Post!
sorentwo
You summarized it nicely.
One small note regarding Oban’s cron and how it interplays with uniqueness: the cron plugin inserts a single job which may be picked up by any node, just like any other job.
Popular in Questions
Other popular topics
Latest Oban Threads
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









