How does systemd decide if a service is ok or not
Solution 1:
systemctl status
does not provide advanced information on the service running.
If you are looking for ways to notify systemd about status changes on your service, sd_notify
might be helpful. This depends on your services ability for self-diagnosis, though. If your service uses sd_notify, you can configure the service with
WatchdogSec`. To cite from the documentation:
Configures the watchdog timeout for a service. The watchdog is activated when the start-up is completed. The service must call sd_notify(3) regularly with "WATCHDOG=1" (i.e. the "keep-alive ping"). If the time between two such calls is larger than the configured time, then the service is placed in a failed state and it will be terminated with SIGABRT.
However using systemctl show
you can retrieve some additional machine-readable information on the service, which might help you deciding if the service is okay.
In case you are looking for systemd
to tell if your service runs in an infinite loop, your are most likely out of luck. That problemis closely related to the halting problem, for which is proven that no general algorithm to solve the problem exists.
While your specific problem might be solvable, it is most likely at least an enormous waste of resources. See this related question.