ubuntu - How to pass environment variables to a service started by systemd -


i have nodejs service built using nodejs. service requires environment variables passed it. moreover, created systemd unit file start systemctl. weird reasons, service, when started systemctl, not read environment variables. instance, 1 environment variable host, contains ip sails app binded. however, if start service sails lift or node app.js, read environment variables. here unit file:

[unit] description=project  [service] execstart=/usr/bin/node /mnt/project/app.js restart=always standardoutput=syslog  [install] wantedby=multi-user.target 

i tried everything. added environment variables /etc/environment , pointed unit file it, added them unit file, nothing worked.

something

[unit] description=project  [service] execstart=/usr/bin/node /mnt/project/app.js restart=always standardoutput=syslog environment=key=value  [install] wantedby=multi-user.target 

https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html

or, alternative :

environmentfile=/path/to/env 

with format :

key=value 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -