Lurker News
I created a TUI for systemd/systemctl called isd (interactive systemd).

It provides a fuzzy search for units, auto-refreshing previews, smart sudo handling, and a fully customizable, keyboard-focused interface for power users and newcomers alike.
It is a more powerful (but heavier) version of sysz, which was the inspiration for the project.
This should be a huge timesaver for anybody who frequently interacts with or edits systemd units/services. And if not, please let me know why! :)

Comments (204) 37 threads

Show all comments

Showing thread 1 of 37

ww5202 replies#
Looks nice.

One thing I found systemd really confusing was its treatment of ExecStop in a service script. ExecStart is the command to run when systemd starts the service at system boot up (or when a user tells systemd to start the service). However, ExecStop is run when the starting command has finished running. You have to set RemainAfterExit=yes to have the desired function of running the stop command on system shutdown or on user stopping the service. ExecStop is basically the "on-cleanup" event rather than "to-shutdown-the-service" event.

Cyph0n1 reply#
I think about them as “on start” and “on stop”.

It is important to keep in mind that systemd is tailored towards daemons. So if your service just runs a command that eventually exits, you need to explicitly tell systemd to treat it differently than a daemon.
Edit: As others noted, you’re probably looking for oneshot + RemainAfterExit.

rcxdude1 reply#
It is a little asymmetric, because 'ExecStart' is actually normally 'Executable that is the service', not just script that starts the service, but I think that's a hangover from the self-daemonizing approach to init scripts.
Cyph0n3 replies#
True, but it still makes sense to reason about them this way. Say you have an HTTP server:

- on start: start the server
- on stop: do nothing, because you are already terminating the server
But suppose you need to perform an additional task when the server is terminated. That is where you would add a ExecStop command or script.

Continue this thread — 3 replies

yread1 reply#
ExecStop works the way you want for type=forking
ww5201 reply#
Still has the same problem even with type=forking. Only way to get it working was RemainAfterExit=yes
shawnz12 replies#
I think you actually probably want type=oneshot (and also RemainAfterExit=yes) for the kind of service you're describing

Continue this thread — 12 replies