简体   繁体   中英

Why edeliver generates incorrect sys.config on restart

My goal is to add a new application environment variable to an Elixir/Phoenix app, which is released with the distillery and deployed with the edeliver.

Because I've added a new value to the prod.secret.exs file, I'm expecting the new env variable to be not nil when I'm calling Application.get_env(:my_app, :key) on the production host.

Instead, I'm getting nil . The fix I've applied is to stop the app, remove everything and deploy a brand new release. I guess it's not the correct fix.

So, how to correctly add new config variables?

What I've noticed so far. I'm putting the configuration I need to the prod.secret.exs file and it's successfully used by distillery during the build process. In the generated release, the sys.config file contains the new config vars. But var/sys.config file of the deployed app does not contain the new config. If I manually put new config to the var/sys.config and restart the release, then the var/sys.config is regenerated without the new config vars.

Mix configs are compile-time configs, meaning that if you fetch a environment variable inside of your config this will be done at the compilation stage of the project.

So, in your case when you build the project, it looks at the environment variable and hardcodes it in your compiled binaries. At each run it looks at those values that were already fetched before.

Elixir 1.9 introduced release configs via Config and distillery supports it, you can read more detailed about this in one of my answers .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM