I have many environmental variables that are required to run my ruby rake job. This job will be supervised by systemd.
How can I export all the environmental variables?
And also export them in such a way so that only my systemd service will see them, if this possible.
Here's my service which has only a single environmental variable in it:
$ cat /etc/systemd/system/my_service.service [Unit] After=syslog.target Requires=mysql.service [Service] WorkingDirectory=/home/ubuntu/my_app/app1 ExecStart=/bin/bash -lc 'source /home/ubuntu/.profile && bundle exec rake jobs:job1' Restart=on-abort RestartSec=10 StandardOutput=syslog StandardError=syslog SyslogIdentifier=app1_bg_jobs User=ubuntu Group=ubuntu Environment=RAILS_ENV=staging [Install] WantedBy=multi-user.target
I don't want to use the key
Environment because there're many variables and some may contain
$HOME which won't be resolved in systemd