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:
- When starting beam, kernel application will start
application_controllerprocess, who will load all env’s insys.config, which is generated via theconfig/config.exs(this is the compile time config). All the application’s env are stored in an ets table calledac_tab. - After all application started, some code will load the configs in
config/releases.exs, and updateac_tabwith runtime config - Then a restart beam command is issued, maybe via
:init.restart(), all the application is shutdown - 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
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
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.







