Created
November 16, 2015 23:00
-
-
Save danechitoaie/f2bb03fd0c2d6b803878 to your computer and use it in GitHub Desktop.
Virtualenv Systemd Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Python Virtualenv service example | |
After=network.target | |
[Service] | |
User=my_user | |
Group=my_group | |
Environment=VIRTUAL_ENV=/home/my_user/.virtualenvs/my_venv | |
Environment=PATH=$VIRTUAL_ENV/bin:$PATH | |
ExecStart=$VIRTUAL_ENV/bin/my_entrypoint | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
Systemd does not expand environment variables.
You end up with literal $VIRTUAL_ENV
and $PATH
inside the PATH variable
and in path to the executable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jcaesar you are right: I'm getting the following error (when trying to start the unit):
So a fix would be:
See also: https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart=