Systemd startup script not working

systemd

I created a systemd startup script that simply calls a python script with start or stop args .The script works if run manually from the shell but when I run systemctl start foo or systemctl stop foo it doesnt work

[Unit]
Description=foo Backends
After=network.target remote-fs.target nss-lookup.target

[Service]
ExecStart=/opt/foo/scripts/init_backends.py start
ExecStop=/opt/foo/scripts/init_backends.py stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Note that calling /opt/foo/scripts/init_backends.py start from the shell works just fine

Best Answer

It started working when using the following setting. I think the StandardOutput=tty was the key

[Unit]
Description=foo Backends
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/opt/foo/scripts/init_backends.py start
ExecStop=/opt/foo/scripts/init_backends.py stop
User=root
Group=root
TimeoutSec=300
StandardOutput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Related Topic