On a server I run Arch Linux. I have an env variable set:
// in /etc/environment
I’ve reconnected to a server to reload the file. Then I connect to a node or Elixir app on that server:
> System.get_env "MY_VAR"
I disconnect from a node and the variable is set, as it should:
How do you start your application?
Personally I have never used
/etc/environment, I do either set the environment on a per user level in their respective environments or shells RC files or for services in the unit description.
Since I never used that file to set env vars, I’m not sure from what point on it will be available and if systemd controled services would “see” its content.
Actually, I even have the same var in
That one is definitively not read by
systemd, even if you set the
User directive accordingly.
The save way to inject environment variables into a
systemd service unit is to use
but /etc/environment is read
I have googled a bit. And it seems as if
/etc/environment is not read for services, but only for user sessions. You can set it as
EnvironmentFile in the unit description, but I’d not do this for env vars that contain secrets, as every user will be able to see that one.
How do you set env. variable in your apps?
As I said already, I use the
Environment directives in the unit file.