[erlang-questions] Dealing with different environment configurations?

Motiejus Jakštys desired.mta@REDACTED
Fri Mar 21 18:36:18 CET 2014

Sharing to list, since might be interesting for more people.

2014.03.21 17:30, Roger Lipscombe rašė:
> The problem I had with that is that it expects either fully-qualified
> paths, which means we need to know where the package is going to be
> installed (I mean, we do, but it seems brittle). Or it looks for
> config relative to the VM working directory. If you're using the relx
> start script, that's one up from the 'bin' directory.
>>> We use 'priv/extra.config' for environment-specific configuration.
> And do you keep that 'priv' directory next to the 'bin', 'lib',
> 'releases' directories, etc.? That might work. Do you then deploy a
> separate file into that location on a per-environment basis.

We use RPM for deployment; creating a symlink in the correct path
pointing to the "real" file is part of the application RPM spec.

That also means you have to be careful about config compatibility,
because they are managed externally. However, priv/extra.config is
limited to really simple values, so it's usually fine.

>>> You might run into problems if you depend on these values from eunit,
> I didn't think eunit (even with rebar) could use a config file.

Some applications require some external settings for running tests (like
DB credentials). For these, invoke rebar like:

ERL_FLAGS="-config rel/files/sys.config" rebar eunit <...>

And we have priv/extra.config in application directory, which is
generated on setup time. So running tests from scratch:

$ git clone <app>; cd <app>
$ make  # get-deps, compile
$ make setup MYSQL_USER=....  # generate priv/extra.conf and stuff
$ make test  # "rebar eunit" with necessary flags and ENV


More information about the erlang-questions mailing list