Manage application env from rebar3 profile

I Gusti Ngurah Oka Prinarjaya okaprinarjaya@REDACTED
Sat Nov 16 19:41:08 CET 2019


Hi,

Yes it's possible.

You can utilise sys.config with configurations content like below:

[
  {YOUR_APP_NAME, [
    {your_env_var1_defined_in_os_in_lowercase,
"${YOUR_ENV_VAR1_DEFINED_IN_OS}"},
    {your_env_var2_defined_in_os_in_lowercase,
"${YOUR_ENV_VAR2_DEFINED_IN_OS}"},
    {your_env_var3_defined_in_os_in_lowercase,
"${YOUR_ENV_VAR3_DEFINED_IN_OS}"},
    .... you can define more here as much as you want
  ]}
].

Then, in order to be able shipping / bring sys.config into your release,
you need to treat sys.config as a dynamic configuration source file.

Follow steps below:
1. create a directory named config at root APP / project directory
2. create file sys.config inside config/ directory
3. the edit your rebar.config as below:

{shell, [
  {sys_config_src, "config/sys.config.src"},
  {apps, [APP_NAME]}
]}.

{relx, [
  {sys_config_src, "config/sys.config.src"},
  {
    release,
    {APP_NAME, "0.1.0"},
  },
  {dev_mode, true},
  {extended_start_script, true}
]}.

For further information you can read here:
http://www.rebar3.org/docs/releases#section-dynamic-configuration
and here: http://www.rebar3.org/docs/dynamic-configuration (more advance)

Hope it helps.




Pada tanggal Min, 17 Nov 2019 pukul 00.38 Nyirő Gergő <gergo.nyiro@REDACTED>
menulis:

> Dear list,
>
> I would like to change some constant during testing e.g.: cycle time
> of a periodic job.
> It would be ideal to manage it from rebar3 config, but I don't see how
> should I edit
> the application env variables from rebar3 profiles. Is that even
> possible? Should I use
> persistent_term instead of application:get_env?
>
> Thanks for your help in advance,
> Gergő
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20191117/b15b53d7/attachment.htm>


More information about the erlang-questions mailing list