Centos – systemd keeps stopping and restarting a service

centos-7servicessystemctlsystemd

Before systemd, my /etc/init.d/referee script would start/stop/restart a service without issue. Converting to systemd, which calls the same init.d script, the service starts without an error and then is somehow promptly called again with a stop.

When I run the service manually, the service starts and continues without issue. When started manually, the "systemctl status referee" shows the service as active (running)

I've have Type=forking. Is there another setting I need?

My system:

Distributor ID: CentOS
Description:    CentOS Linux release 7.1.1503 (Core) 
Release:    7.1.1503
Codename:   Core

A /etc/systemd/system referee.service file:

[Unit]
Description=keeper service
After=rc-local.service
After=syslog.target

[Service]
ExecStart=/usr/local/keeper/initscripts/referee start
ExecReload=/usr/local/keeper/initscripts/referee restart
ExecStop=/usr/local/keeper/initscripts/referee stop
Type=forking
# restart automagically after a reboot
Restart=always
RestartSec=10

[Install]
WantedBy=basic.target

Best Answer

It seems the Type=forking was causing the restarts. A better way was to remove the Type and use PIDFile= instead.

Related Question