Systemd: Service restarts every 90 seconds

servicessystemd

We have written a service script for systemd to start an executable on system start up. The service script restarts every 90 seconds on a consistent basis. If we disable the service and run the executable, it runs as expected. We are using Yocto Linux on an Intel Edison.

Here is our startup script:

[Unit]
Description=patsuit
After=network-online.target
Wants=network-online.target

[Service]
WorkingDirectory=/home/root
Type=forking
ExecStart=/bin/PatDownSuitFirmware/PatDown_V3
User=root
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target

Best Answer

You have a readiness protocol mismatch. You've told systemd that your program forks a child process and then exits the parent process to signal that it is ready. But in fact your program does not do that. Since it hasn't stated that it is ready within 90 seconds (the default start timeout), systemd has decided that your service has failed. Failed services get everything killed off. Becuase of on-failure, your failed service is then restarted, and the cycle repeats.

Use the readiness protocol that correctly describes what your program actually does. That, you have not told us.

Further reading

Related Question