Sample Header Ad - 728x90

Systemd service fails to start Python project

0 votes
1 answer
2732 views
I am trying to make a project written on Python work on a server. I created the following service file: [Unit] Description=My bot service After=multi-user.target [Service] Type=simple Restart=always ExecStart=/usr/bin/python3.10 /home/path/to/bot.py [Install] WantedBy=multi-user.target But this code doesn't work. If I check service status, it returns the following: ● test.service - My bot service Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2022-10-21 08:16:07 UTC; 15s ago Process: 156695 ExecStart=/usr/bin/python3.10 /home/path/to/bot.> Main PID: 156695 (code=exited, status=1/FAILURE) Oct 21 08:16:07 instance-1 systemd: test.service: Scheduled restart job, restart coun> Oct 21 08:16:07 instance-1 systemd: Stopped My bot service. Oct 21 08:16:07 instance-1 systemd: names.service: Start request repeated too quickly. Oct 21 08:16:07 instance-1 systemd: test.service: Failed with result 'exit-code'. Oct 21 08:16:07 instance-1 systemd: Failed to start My bot service. When I execute the bot directly (/usr/bin/python3.10 /home/path/to/bot.py), it works. When I run a simple Python script as a service, it also works. I just don't understand what can cause the problem inside the project. Adding WorkingDirectory parameter into the configurational file didn't change anything
Asked by apazent (21 rep)
Oct 24, 2022, 11:01 AM
Last activity: Jan 28, 2025, 10:00 AM