sorentwo/oban

Node name not set from DYNO var with mix release on Heroku

Closed this issue · 3 comments

Environment

  • Oban 2.17.8, Oban Pro 1.4.6
  • PostgreSQL 15.6
  • Elixir 1.16.2 / 26.2.4

Current Behavior

This application deploys on Heroku. When switching from executing via mix phx.server to mix releases (via https://github.com/elixir-buildpack/heroku-buildpack with the release=true option), the node name in the Oban web ui changed from worker.1 (e.g. the DYNO ENV value) to app_name@hostname.

Expected Behavior

It would be nice if Oban picked up the DYNO value at runtime.

Workaround

Set node explicitly in config/runtime.exs.

#config/runtime.exs

config :my_app, Oban,
  node: System.get_env("DYNO") || :inet.gethostname() |> elem(1) |> List.to_string(),
   ...

Notes

Unlike, #170, we're not setting a hostname explicitly, the hostname that comes through is a uid set by Heroku on the VM.

That's because the node is considered "alive" by default when it's part of a release, and the first condition uses the node() name if the node is alive. The behaviour was established at a time when releases weren't as ubiquitous and runtime.exs didn't exist. Changing the order to look for DYNO first feels backwards now.

I believe the best approach is to document setting the node option in runtime.exs. Would you open a PR?

Closed with #1078

Thanks!