I have a server with Ubuntu 22.04.2 LTS and I need to create a service that would be running on the server. I found this SO answer which details how to create and enable a service, however my service fails with Failed with result ‘exit-code’.
These are the steps that I performed to create the service:
sudo nano /lib/systemd/system/scrapyd.service
[Unit] Description=Scrapyd service After=network.target [Service] User=root Group=root WorkingDirectory=/home/projects ExecStart=/usr/local/bin/scrapyd [Install] WantedBy=multi-user.target
/home/projects is the directory where are my projects which would use the scrapyd
service. The ExecStart
– I used the same path as in the “tutorial”. If I cd
into /usr/local/bin/
, there’s no scrapyd.
-
I ran
systemctl enable scrapyd.service
and the terminal outputtedCreated symlink /etc/systemd/system/multi-user.target.wants/scrapyd.service → /lib/systemd/system/scrapyd.service.
-
I ran
systemctl start scrapyd.service
(there was no output) -
Finally, I ran
systemctl status scrapyd.service
and got this error:
× scrapyd.service - Scrapyd service Loaded: loaded (/lib/systemd/system/scrapyd.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2024-04-21 20:43:34 UTC; 41s ago Process: 792557 ExecStart=/usr/local/bin/scrapyd (code=exited, status=203/EXEC) Main PID: 792557 (code=exited, status=203/EXEC) CPU: 2ms Apr 21 20:43:34 SERVER systemd[1]: Started Scrapyd service. Apr 21 20:43:34 SERVER systemd[1]: scrapyd.service: Main process exited, code=exited, status=203/EXEC Apr 21 20:43:34 SERVER systemd[1]: scrapyd.service: Failed with result 'exit-code'.
What is the proper way to set up a new service on Ubuntu?