0

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

  • "Doesn't work" how? What do you expect to happen, what happens instead, what do the logs say? – Jenny D Jun 20 '15 at 7:20
  • journalctl -u foo_backends.service says Jun 20 03:19:53 centos7.bingooo.net systemd[1]: Started foo Backends – Anoop P Alias Jun 20 '15 at 7:22
  • The python script is supposed to start multiple php-fpm processes using subprocess.call and when do it leaves behind multiple php-fpm master process – Anoop P Alias Jun 20 '15 at 7:24
2

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.