I wrote a small app. The app works great. However I am trying to create a service file and I am running into issues. Running the command sudo uwsgi uwsgi.ini
works. App starts up. I created a service file.
[Unit]
Description=uWsgi instance to start relay site
After=network.target
[Service]
User=pi
Group=pi
WorkingDirectory=/var/www/relay
ExecStart=sudo uwsgi uwsgi.ini
[Install]
WantedBy=multi-user.target
The service file errors when I try to start it.
Loaded: error (Reason: Invalid argument)
relay.service: Unit entered failed state.
relay.service: Failed with result 'exit-code'.
[/etc/systemd/system/relay.service:11] Executable path is not absolute, ignoring: uwsgi uwsgi.ini
relay.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
[/etc/systemd/system/relay.service:9] Executable path is not absolute, ignoring: sudo uwsgi uwsgi.ini
relay.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
It says Executable path is not absolute
because the executable is sudo
and not /usr/bin/sudo
. Systemd needs the full path because it does not use a shell as you do when you use a terminal.
Also, if you're going to sudo
the command then you might as well use root
as the user instead (which is the default). Something like this should work:
[Service]
WorkingDirectory=/var/www/relay
ExecStart=/absolute/path/to/uwsgi uwsgi.ini
You can run which uwsgi
to find the absolute path to uwsgi
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.