systemd keeps stopping and restarting a service
5,771
It seems the Type=forking was causing the restarts. A better way was to remove the Type and use PIDFile= instead.
Related videos on Youtube
Author by
user2569618
Updated on September 18, 2022Comments
-
user2569618 over 1 year
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
-
sscirrus over 6 yearsFor others experiencing a similar problem - I found that I had the wrong user. Running the script as root fixed the problem.
-