Where to configure run_erl environment variables in 1.9's mix release?

With the built-in release task provided in Elixir 1.9, i dont know where to configure environment variables related to Erlang.

In distillery, i used to configure in the rel\config.exs file, like below:

environment :prod do
  set vm_args: "rel/vm.args"
  set run_erl_env: "PIDFILE=/srv/folder/bin/service.pid RUN_ERL_LOG_MAXSIZE=100000000 RUN_ERL_LOG_GENERATIONS=20"
end

In 1.9 release, i dont know where to configure this type of environment variable. Any clues?

Have a look at rel/env.sh.eex or (if you’re deploying to Windows) re/env.bat.eex.

I successfully set RUN_ERL_LOG_MAXSIZE and RUN_ERL_LOG_GENERATIONS. But make sure to export them, otherwise they won’t be seen by run_erl.

1 Like

Thanks!
I saw this option, but i’m not sure if this variables will be set to the entire host that the release is running.

I have 5 or more elixir applications running in the same machine. Do you know if this option will affect them all?

What do you mean by 5 applications? Application in Erlang sense, or in OS sense?

If you mean you have something like Umbrella apps, then making one release for all of them, yes it would work. As long as you package them together in one release and start them together, it would work. If you are making different releases for different application, then I’m not sure, but it should work this way. IDK if the different releases use different env.sh files or not, but if they do you should be able to update them too.

If you mean 5 different applications on 5 different BEAMs, then you have 5 different releases. Then you should change each release accordingly. The way does not change, just that you have 5 files to edit, probably once and for all.

Another way is also to start you release like RUN_ERL_LOG_MAXSIZE=100000000 RUN_ERL_LOG_GENERATIONS=20 /path/to/realease/bin/name start. You get the idea. You can also put these variables in files like ~/.bashrc (or another one based on your shell). It does not make any difference. Just make sure you close your shell after editing ~/.basrc so changes would apply. Check with env to see if they are set.

Wherever you put the variables, just don’t forget to export them. This little thing bite me just some hours ago! :slight_smile:

I feel that your are not the developer of these application. You are the devops guys right?

If that’s the case, and more apps are coming later too, then probably editing ~/.bashrc would be a better choice, so you don’t rely on developers setting some configuration for you.

Also if you are using systemd or sysv or supervisor or any solution like them, they have their own way of setting environment variables. Look at their docs, that may prove helpful too.

I meant 5 Elixir applications. They are not umbrella apps.

I ask that because i don’t want to a variable that is set in one specific app, affect another app.

Example: In App1 i set RUN_ERL_LOG_GENERATIONS=20 and in App2 i set RUN_ERL_LOG_GENERATIONS=5. Each app has a different release, tho.

Because, i was thinking that this variables will be seted global, but with your response i think that not. And this is the behaviour that i expect.

Thanks for your time and explanation. Have a good day!

Just to be more clear for you and later dear readers, no, environmental variables set for one app will not affect another app.

That’s actually the doing of the start script. It will source env.sh before actually running run_erl, so different apps won’t interfere.

1 Like