Ubuntu – Fix Error Adding Supervisord to Run via Systemd

supervisordsystemdUbuntu

I am trying to run supervisor from systemd and I am following this tutorial here.

Upon creating this file /etc/systemd/system/supervisord.service with the following contents:

[Unit]
Description=Supervisor daemon
Documentation=http://supervisord.org
After=network.target

[Service]
ExecStart=/usr/local/bin/supervisord -n -c /etc/supervisor/supervisord.conf
ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
Alias=supervisord.service

When I run it I get the following error:

Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: Started Supervisor daemon.
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[8772]: supervisord.service: Failed to execute command: No such file or directory
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[8772]: supervisord.service: Failed at step EXEC spawning /usr/local/bin/supervisord: No such file or directory
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Main process exited, code=exited, status=203/EXEC
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Failed with result 'exit-code'.
Mar 17 01:19:04 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Service hold-off time over, scheduling restart.
Mar 17 01:19:04 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Scheduled restart job, restart counter is at 1.
Mar 17 01:19:04 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: Stopped Supervisor daemon.

Clearly it says that there is no such directory, but is creating one actually the correct way to solve the problem?

The reason why I am unsure is because when looking at other (I guess) similar issues (example: here), they seem to fix it differently. Also in the tutorial, it does not mention this path (the one that does not exist) anywhere else besides in the contents of supervisord.service, so I am quite confused what is happening here.

Can anyone please explain to me or point me to something specific to read in order to solve my problem in the correct way?

Thanks!

UPDATE

locate supervisord yields:

/etc/supervisor/supervisord.conf
/etc/systemd/system/supervisord.service
/usr/bin/echo_supervisord_conf
/usr/bin/supervisord
/usr/lib/python2.7/dist-packages/supervisor/supervisord.py
/usr/lib/python2.7/dist-packages/supervisor/supervisord.pyc
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisord.py
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisord.pyc
/usr/share/man/man1/echo_supervisord_conf.1.gz
/usr/share/man/man1/supervisord.1.gz
/var/log/supervisor/supervisord.log

locate supervisorctl yields:

/usr/bin/supervisorctl
/usr/lib/python2.7/dist-packages/supervisor/supervisorctl.py
/usr/lib/python2.7/dist-packages/supervisor/supervisorctl.pyc
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisorctl.py
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisorctl.pyc
/usr/share/man/man1/supervisorctl.1.gz

Best Answer

Your service file is specifying the wrong locations for the binaries.

In the file, change

/usr/local/bin/supervisord

To

/usr/bin/supervisord

And

/usr/local/bin/supervisorctl 

To

/usr/bin/supervisorctl 

Next, run the command systemctl daemon-reload and then systemctl start supervisord.