1

We build the following service on redhat machine version 7.2

more king.service

[Unit]
Description=king Daemon
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]

ExecStart=/opt/home/king/king-server-0.216/bin/launcher start
ExecStop=/opt/home/king/king-server-0.216/bin/launcher stop

Type=forking
PIDFile=/opt/home/king/data/var/run/launcher.pid
Restart=always
RestartSec=10
StartLimitInterval=400
StartLimitBurst=5

[Install]
WantedBy=multi-user.target

Now we stopped the service

systemctl stop  king.service

now we check the status of king service

systemctl status  king.service
● king.service - king Daemon
   Loaded: loaded (/etc/systemd/system/king.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-03-28 10:39:23 UTC; 35s ago
  Process: 26595 ExecStop=/opt/home/king/king-server-0.216/bin/launcher stop (code=exited, status=0/SUCCESS)
  Process: 26300 ExecStart=/opt/home/king/king-server-0.216/bin/launcher start (code=exited, status=0/SUCCESS)
Main PID: 26306 (code=exited, status=143)

So service is down

Now , we start the script itself - /opt/home/king/king-server-0.216/bin/launcher start ( instead to do it from the service )

/opt/home/king/king-server-0.216/bin/launcher status
Running as 27286

Before I continue , as I understanding now we should see the service is up , because we start the script

But when we check the service we see that service still down , in spite the script is running

systemctl status  king.service
● king.service - king Daemon
   Loaded: loaded (/etc/systemd/system/king.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-03-28 10:39:23 UTC; 35s ago
  Process: 26595 ExecStop=/opt/home/king/king-server-0.216/bin/launcher stop (code=exited, status=0/SUCCESS)
  Process: 26300 ExecStart=/opt/home/king/king-server-0.216/bin/launcher start (code=exited, status=0/SUCCESS)
Main PID: 26306 (code=exited, status=143)

So why service not follow according to the script ?

Where I am wrong here?

4
  • 1
    systemctl status only knows that you didn't run systemctl start. After stopping, the contents of the PID file are potentially incorrect, so there's no way of knowing if the process is running. As you found out, it is not safe to bypass systemd in this way. Commented Mar 28, 2019 at 11:33
  • but lets say I kill the PID ( example kill 4354 ) of the script , then service should start the script again after 10sec - am I right ?
    – yael
    Commented Mar 28, 2019 at 11:45
  • do you see some issue with my service configuration?
    – yael
    Commented Mar 28, 2019 at 12:02
  • It also overlaps unix.stackexchange.com/q/393356/5132 and unix.stackexchange.com/q/437251/5132 .
    – JdeBP
    Commented Mar 28, 2019 at 12:11

0

Browse other questions tagged .