1

I got a daemon in centos 7 that I'm trying to setup for execution on boot via systemd. The daemon is a binary (c source) that does a fork and change of id/group.

The trouble I'm having is systemd seems to kill the daemon after a timeout period. I'm not sure if it thinks the process did not start correctly or if it's trying to see if it is still active. Anyway here is the status info:

[root@billing init.d]# systemctl status bx_edge.service
bx_edge.service - BillMax Customer Portal Daemon
   Loaded: loaded (/etc/systemd/system/bx_edge.service; disabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Thu 2016-09-22 00:02:48 UTC; 48s ago
  Process: 10611 ExecStop=/bin/pkill edge (code=exited, status=0/SUCCESS)
  Process: 10606 ExecStart=/usr/local/billmax/bin/edge -i -o (code=exited, status=0/SUCCESS)
 Main PID: 10609 (code=exited, status=0/SUCCESS)

Sep 22 00:01:18 billing.billmax.com systemd[1]: Starting BillMax Customer Portal Daemon...
Sep 22 00:01:18 billing.billmax.com systemd[1]: Started BillMax Customer Portal Daemon.
Sep 22 00:02:48 billing.billmax.com systemd[1]: bx_edge.service stop-sigterm timed out. Killing.
Sep 22 00:02:48 billing.billmax.com systemd[1]: Unit bx_edge.service entered failed state.
Sep 22 00:02:48 billing.billmax.com systemd[1]: bx_edge.service failed.

My service file looks like:

[Unit]
Description=BillMax Customer Portal Daemon
After=network.target

[Service]
ExecStart=/usr/local/billmax/bin/edge -i -o
ExecStop=/bin/pkill edge
Type=forking

[Install]
WantedBy=default.target

What is causing this? I've tried changing the Type value but that results in the same behavior.

Bill

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
user44021
  • 11
  • 1
  • 4
  • 1
    The `ExecStop=` is redundant and unnecessary. And it's risky, since it doesn't just kill the service, but any program named `edge` (of which there could be many). Better to kill `$MAINPID`, and best to just omit the whole line entirely; systemd knows how to send a signal to a service. – Michael Hampton Sep 22 '16 at 01:01
  • 1
    Anyway, this happens because _the program did not actually fork_ within the timeout period (which here is 90 seconds). Look into why that is. – Michael Hampton Sep 22 '16 at 01:03
  • 1
    I have complete control of the system this runs on and edge is unique. Well aware of the consequences. Anyway more interested in your redundant and did not fork comments. How does the stop occur otherwise? How does systemd know which process to kill? The program did fork. So I assume it doesn't know this. After reading the docs more, I now see that the process needs to write its own pid file and I need to provide the file name for it via the PIDFile setting. Once I did that the timeout stopped occurring. – user44021 Sep 22 '16 at 14:35

0 Answers0