[systemd-devel] Start and stop requests for a service

Umut Tezduyar umut at tezduyar.com
Fri Sep 27 02:37:47 PDT 2013


Hi,

I have noticed that ExecStop is not being run on following service
with following requests:

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "sleep 20 && /usr/bin/systemd-cat echo ExecStart.."
ExecStop=/bin/sh -c "/usr/bin/systemd-cat echo ExecStop.."


$> systemctl start hello.service &
$> systemctl stop hello.service

I have couple discussions:

1) When a "oneshot" service is being in activating state, why doesn't
"stop" request wait for the service to become "active"? I would expect
systemd to queue "stop" request as long as service is in "activating"
state. I think this kind of behavior is fine for Type=simple but not
for Type=oneshot. KillMode=none is the only way to provide atomicity.

2) If I have an "ExecStop" directive, I would expect it to run no
matter what. My solution is moving ExecStop to ExecStopPost.


-------------------------------------------------

My use case: I have a service which sets up ip filters on ExecStart
and removes the filters on ExecStop. Setting up ip filters is done by
a script. I have ended up finding my target in an inacceptable state
due to "start" "stop" request coming right after each other.

Thanks,
Umut


More information about the systemd-devel mailing list