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.

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
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

We're in Beta

About us Mission Statement