sbs

sbs

Elixir 1.9 runtime config what's the reason behind restarting beam

Elixir 1.9 provides runtime config. When set it up by providing a config/releases.exs, it will copy this file to _build/prod/rel/APP/releases/VSN/release.exs and when start the release via bin/App start_iex, it will first start beam, then restart beam within the same os process, then starting again.

I’m not quite sure what’s the reason behind restarting beam? Here’s my guess:

  1. When starting beam, kernel application will start application_controller process, who will load all env’s in sys.config, which is generated via the config/config.exs(this is the compile time config). All the application’s env are stored in an ets table called ac_tab.
  2. After all application started, some code will load the configs in config/releases.exs, and update ac_tab with runtime config
  3. Then a restart beam command is issued, maybe via :init.restart(), all the application is shutdown
  4. Then all the application is starting again, but this time with runtime config inserted in ac_tab, so the application will have access to the runtime config when they starts

Is that why beam needs to restarts when runtime config is provided?

Most Liked

michalmuskala

michalmuskala

The reason for restart is to allow configuring the kernel and stdlib applications, in particular, various distribution flags. Otherwise, since as you said, kernel is started before config is loaded, you wouldn’t be able to change those configurations.

LostKobrakai

LostKobrakai

There’s a :reboot_system_after_config setting for mix release, which allows for loading config without the reboot (cannot configure kernel and stdlib as mentioned). It seems to be buggy on 1.10 with releases.exs, but it should work on 1.11 with runtime.exs.

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New

We're in Beta

About us Mission Statement