Closed tylerjl closed 8 years ago
Hi @tylerjl, thanks for this! I think your proposal sounds spot on. I don't think I've really used one shot services, so I bow to your superior wisdom. If you're happy to code it up and submit a PR then I'll test it. Thanks again!
Hey @joonty, I've been digging around in the code again and wanted to propose extending functionality to address use cases that include
oneshot
services (a github issue seems like the best place for this discussion, let me know if it belongs elsewhere.)To illustrate, the use case I'm thinking of would be a cron replacement using
timer
units and oneshotservice
units. Each time a timer triggers its accompanyingservice
unit, as long as systemd doesn't see a nonzero exit code, the service unit does not go into a failure state but remainsinactive (dead)
(after briefly transitioning toactivating
.) However, for a oneshot service that does notRemainAfterExit
, this is basically still a "good" state to be in - it just means the last service execution was a success (nonzero exit.)Currently, when trying to use systemd_mon with oneshot services, I get errors about calls to
first
instate_change.rb
.The current state paradigm indicates that
inactive
is a bad state, but for oneshot services, this could actually beok
. The "important" states in the case of a oneshot would be whether ActiveState is inactive or failed.I think the easiest way to implement this may be to pass the
Type
of a service unit to theState
constructor and, ifoneshot
, alter the possibleok_states
andfailure_states
thatActiveState
can take on (I thinkType
is a gettable property from the unit's dbus handle.)Does this sound like a reasonable + good idea? I'm asking before coding it up because my ruby is kind of rusty and want to confirm this would work for the way you've got the state change algorithm set up; I don't grok it fully. :smile: If so I'll throw a PR together, the aforementioned implementation doesn't seem hard, just needs to fit correctly into the current paradigm you've got going.