amnu3387

amnu3387

Distillery and compile time ENV variables not being used on restart

Hey, hope any one more experienced with Distillery can shed some light on this issue.

So I have read through quite a bit of disparate sources on how to access env variables when deploying through Distillery. What I ended up doing was to create a prod.secret.exs the deployment user folder. This works - I’ve used interpolated values with “${…}” on my ~/.profile I have:

export REPLACE_OS_VARS=true

On /.deliver/config I have the following hook pointing to the prod.secret.exs on the server.
pre_erlang_get_and_update_deps()

And I also uncommented the load profile line on the clean_compile hook.

pre_erlang_clean_compile() {
	status "Running phoenix.digest" # log output prepended with '---->'
	__sync_remote " # runs the commands on the build host
	  -f ~/.profile ] && source ~/.profile # load profile (optional)
	  source ~/.profile
...
}

This is for the compilation and is working as expected. Whenever I build and release, or upgrade and release the correct ENV variables are fetched from the ENV, and used in the interpolation in prod.secret.exs

But, whenever I restart through edeliver, or if I reboot the server, no longer are they used.
If I open ~/app/var/sys.config the correct values appear on the erlang config.

If I go to a release where I restart the server and open sys.config (e.g. ~/app/releases/0.0.11/sys.config), those values are not interpolated, whereas if I check on a release that wasn’t rebooted they are.

What else am I missing about it in order to have them correctly populated on reboot? Or do I need a different setup altogether to have this working, like fetching from env and setting them on runtime? If so anyone knows a good place to check an example of how to hook that up before app start?

Thanks

Most Liked

wmnnd

wmnnd

I am personally not a big fan of prod.secret.exs because I find that it is generally better if a production system can be configured with environment variables following the Twelve-Factor App principles.

You could debug whether your .profile is run by simply logging the result of System.get_env/0 and verifying that all your required variables (including REPLACE_OS_VARS) are set.

Last Post!

amnu3387

amnu3387

Yes I agree - I will try to figure out why it’s happening or find another solution for this, thanks

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement