What do I mean by custom actions? Here are some examples.

sudo service apache2 stop-htcacheclean   
sudo service apache2 graceful-stop
sudo service apache2 start-htcacheclean
sudo service apparmor recache

How can these be re-implemented when porting sysvinit scripts to systemd services?

The problem with systemd is, that differentiating daemon arguments cannot be conditionally used?

And how to do so while adhering with Debian policy?

Or do you know any example Debian systemd services that already support such custom/legacy actions?


systemd does not support custom actions on units.

To explain "why": a unit is (primarily) something that participates in dependency graph. Adding custom actions means that there should be a way to add custom-typed dependencies. This unnecessarily complicates both syntax and logic.

Actually, you may perceive it like a rule: "one unit - one action". Nothing prevents you from having multiple units per application, named like $application-$action. For example:

  • apache2 graceful-stop should probably be the default way of stopping apache (for a non-graceful stop there is always systemctl kill)
  • apache2 {start,stop}-htcacheclean should directly translate to an apache2-htcacheclean.service unit
  • apparmor recache may be either ExecReload= in apparmor.service (or a separate apparmor-recache.service unit with Type=oneshot)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.