Proposal: Remote dynamic configurable elixir application

34 views
Skip to first unread message

Dan Calancea

unread,
Sep 24, 2021, 5:39:03 AM9/24/21
to elixir-lang-core
Let's suppose we have a elixir service that spawns some workers to do a job, the supervisor takes configuration from config and starts the workers. Now the classic way to configure such a project in prod is to use releases.exs, where you can configure environment variables and the release will reload the configuration.

What I want to implement now is a dashboard that will control multiple services configuration, this means that there should be a centralized storage for configuration and some kind of signaling when to change configuration.

Let's suppose we use postgres, some tables to store the configuration and custom signaling/ postgres NOTIFY to notify that the configuration has changed and needs to be reloaded.

The questions that arise are:
  1. Is it possible/recommended to change the releases.exs file responsible for configuration in a release so that the new configuration is persisted across reloads?
  2. Is it possible to implement this for dev environment? since as far as I know dev environment does not support runtime configuration currently.
  3. Is it intended behavior that releases.exs replaces configuration added with Application.put_env/4 with option persistent: true?


Jon Rowe

unread,
Sep 24, 2021, 6:17:41 AM9/24/21
to elixir-l...@googlegroups.com
Hi Dan

Attempting to answer question 2, the most recent version of elixir adds runtime.exs to replace/improve on releases.exs which runs at boot of an Elixir app from mix or a release, see https://hexdocs.pm/elixir/Config.html#module-config-runtime-exs

Cheers
Jon
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

José Valim

unread,
Sep 24, 2021, 6:37:11 AM9/24/21
to elixir-l...@googlegroups.com
In addition to what Jon wrote, it is worth keeping in mind that config/runtime.exs is mostly a wrapper around Application.put_env/4 with option persistent: true, as you well noted, so you can implement the functionality you need using those functions if necessary.

Dan Calancea

unread,
Sep 24, 2021, 7:10:19 AM9/24/21
to elixir-lang-core
Now the only question is: is it possible to restart elixir application programatically from code? I couldn't find any related documentation on this.

José Valim

unread,
Sep 24, 2021, 8:14:46 AM9/24/21
to elixir-l...@googlegroups.com
You can call Application.stop and Application.start.

Reply all
Reply to author
Forward
0 new messages