Where is My Environment Variables? Journey to Linux Service
Ok, I had a .NET Core Web App running in Ubuntu behind Nginx. Everything else is fine except I can't retrieve the value of the environment variables that I put in /etc/environment.
After hours of googling, turns out systemd service strips all out except some variables. Two ways to fix this:
1. Put the environment variable in the .service config file
[Service]
Environment=MY_ENV_VAR=thevalue
2. Include /etc/environment in the service. (I don't think this is a good idea, especially for my use case).
[Service]
EnvironmentFile=/etc/environment
After hours of googling, turns out systemd service strips all out except some variables. Two ways to fix this:
1. Put the environment variable in the .service config file
[Service]
Environment=MY_ENV_VAR=thevalue
2. Include /etc/environment in the service. (I don't think this is a good idea, especially for my use case).
[Service]
EnvironmentFile=/etc/environment
Comments
Post a Comment