Ubuntu: Trouble starting a Python3.5 program as a systemd service



Question:

I created a systemd service titled red-cartridgemom.service:

[Unit]  Description=Red-DiscordBot-CK  After=multi-user.target    [Service]  WorkingDirectory=/home/twop0intfive/server1504/discord_stuff/Red-DiscordBot-CK/Red-DiscordBot/  User=twop0intfive  Group=twop0intfive  ExecStart=/usr/bin/python3.5 /home/twop0intfive/server1504/discord_stuff/Red-DiscordBot-CK/Red-DiscordBot/red.py  Type=idle  Restart=always  RestartSec=15    [Install]  WantedBy=multi-user.target  

However, when I start the service and monitor with journalctl:

Aug 25 18:04:31 server1504 systemd[1]: red-cartridgemom.service holdoff time over, scheduling restart.  Aug 25 18:04:31 server1504 systemd[1]: Started Red-DiscordBot-CK.  Aug 25 18:04:31 server1504 systemd[1]: Starting Red-DiscordBot-CK...  Aug 25 18:04:31 server1504 systemd[3018]: Failed at step CHDIR spawning /usr/bin/python3.5: No such file or directory  Aug 25 18:04:31 server1504 systemd[1]: red-cartridgemom.service: main process exited, code=exited, status=200/CHDIR  Aug 25 18:04:31 server1504 systemd[1]: Unit red-cartridgemom.service entered failed state.  Aug 25 18:04:31 server1504 systemd[1]: red-cartridgemom.service failed.  

...the service never properly starts.

The file at that path definitely exists. I tinkered around with this for awhile until it dawned on me that perhaps systemctl is seeing

/usr/bin/python3.5

as a file 'python3' of type '.5' - is this possible? If so, is there some way to get around this and have systemd 'see' /usr/bin/python3.5 correctly?


Solution:1

So!

Someone in a #support channel suggested running do-release-upgrade (which caused my bots to stop working last time I did it, which is the reason I was running Ubuntu 15.04 up to now) and now, on Ubuntu 15.10, I'm no longer having the issue above. The person who suggested that was running a nearly-identical script as the one I pasted above in Ubunto 16.04.1 and not having the issue I was having.

It seems that the '.' in 'python3.5' indeed was the culprit here, but it also looks like this issue in systemd was fixed sometime in between Ubuntu versions.

tl,dr: this problem doesn't seem to exist on Ubuntu 15.10 and above. The fix for me was to upgrade to 15.10.

Thank you for your time!


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »