[systemd-devel] "Inactive/dead" services that are enabled are indistinguishable from unused or oneshot services

Mike Kazantsev mk.fraggod at gmail.com
Thu Feb 24 00:55:32 PST 2011


Good day,

With systemd on a non-desktop machine, I've stumbled upon such issue:
some services that should be running start and then exit with error
code 0 for some reason, usually unrelated to systemd (in my case it was
a bogus SIGTERM, sent to a wrong process group, but I believe I've
seen it happen because of ordering issues before).

Systemd service file clearly defines service in question as non-oneshot,
but does not define a Restart behavior, so it's assumed that service
should not be restarted if it's exited with any code.

I usually don't want any but the most simple services to be
auto-restarted because the failure (and possible bug/corruption) may
potentially go unnoticed that way, plus it'd add more chaos to the
running system, possibly triggering the chain of restarts/failures that
would be harder to sort out afterwards.

And in case of app failure everything's fine if it exits with >0 code -
service will show up in "systemctl --failed" and some action would be
taken.

Otherwise, "cleanly" exited service that is supposed to be running (as
written in systemd unit spec) looks identical (in systemctl output) to a
lot of other services that are _supposed_ to be in "inactive dead" state
either because they aren't enabled, stopped or have "oneshot" behavior.

Such service could've been stopped manually of course, but list of such
"stopped" (yet enabled) services is also very useful in case you have to
stop a lot of inter-dependent stuff for maintenance and then restart
them all.

Thus, there is no obvious way to reliably check with systemctl whether
enabled services are running or not, which I believe is a very common
sysadmin task, even in presence of external availability monitoring
systems.

Something like "systemctl --enabled" would certainly be much more
useful for such cases than the current "systemctl --all", yet
there will still be a lot of "oneshot" stuff, which are supposed to be
dead, so a separate state for "!oneshot && enabled && exited" services
like "stopped" (in place of "inactive") and maybe a view like "systemctl
--stopped" would be of a great help from my sysadmin's perspective.

I understand that there's already a looong TODO, but maybe it's possible
to cram such systemctl view option(s) somewhere in that list?

Guess I'll try to get this info via dbus in the meantime, and maybe
come with the patch for systemctl, if anyone else think such options
would be useful, so I'd appreciate any feedback on that.


-- 
Mike Kazantsev // fraggod.net




More information about the systemd-devel mailing list