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

3
  • "Doesn't work" how? What do you expect to happen, what happens instead, what do the logs say?
    – Jenny D
    Jun 20, 2015 at 7:20
  • journalctl -u foo_backends.service says Jun 20 03:19:53 centos7.bingooo.net systemd[1]: Started foo Backends Jun 20, 2015 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 Jun 20, 2015 at 7:24

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .