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[1]: test.service: Scheduled restart job, restart coun>
Oct 21 08:16:07 instance-1 systemd[1]: Stopped My bot service.
Oct 21 08:16:07 instance-1 systemd[1]: names.service: Start request repeated too quickly.
Oct 21 08:16:07 instance-1 systemd[1]: test.service: Failed with result 'exit-code'.
Oct 21 08:16:07 instance-1 systemd[1]: 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