i am developing some services scripts that need to be executed on boot on Raspbian (Jessie) and i decided to use systemd. I just started to read some quick tutorials on how to use it, but I have problems with the environment.
The processes that are executed require (in their code) some environment variables that i set in a shell script but they aren't loaded, despite the use of an EnvironmentFile=/path/to/my/file... I have a service executing a Python3 script and another for a Node.js app.
I have been searching for alternative solutions since yesterday, but nothing seems to work... Maybe I just didn't understand how systemd works ? It must be possible to do so, so i am asking you...
Here are my unit files:
For the python script:
[Unit]
Description=My awesome python script
After=multi-user.target
[Service]
ExecStart=/usr/local/bin/python3.6 /home/pi/Desktop/myawesomescript.py
Restart=Always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mypython
User=pi
EnvironmentFile=/home/pi/.bash_vars
[Install]
WantedBy=multi-user.target
The node app:
[Unit]
Description=My awesome Node.js socket.io app
Requires=After=mypython.service # Requires the python script to be running
[Service]
ExecStart=/usr/bin/node /home/pi/Desktop/myawesomenodeapp/src/index.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mynodeapp
User=pi
EnvironmentFile=/home/pi/.bash_vars
[Install]
WantedBy=multi-user.target
Thank you for taking your time and sorry for my bad english !
PS: Please let me know if you need more informations