[systemd-devel] shutdown: how to tell systemd to stop a service before killing other processes
Andrei Borzenkov
arvidjaar at gmail.com
Sun Aug 25 20:02:36 UTC 2019
25.08.2019 19:57, Hans-Dieter Doll пишет:
> On shutdown we need to stop a service before systemd begins to kill all processes it does not know.
> The service is a process supervisor similar to init, which controls all our applications.
> Our applications must be terminated by this supervisor, otherwise data loss and inconsistencies will occur.
>
> The problem is: aside from background processes started by the supervisor, we have applications started in a user
> session, but which are also controlled by the supervisor.
> This is something systemd cannot know, and thus it kills these applications in parallel to shutting down our service.
> So we require systemd to wait for our service to terminate before it begins to kill other processes.
>
> From an arch-linux thread in 2017 I concluded this is not possible due to the design of systemd.
>
> But I cannot believe we are the only one requiring this.
> So my question is: is there nowadays some mechanism available to accomplish this?
>
If your application runs as part of user systemd instance and assuming
recent enough systemd you should be able to order user at .service Before
your supervisor service (via drop-in) so that supervisor will be stopped
before any user sytsemd instance.
If your application runs as user session process, I do not think it is
possible. Session scope unit does not have any Before dependency nor is
it templateable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190825/8552ef71/attachment.sig>
More information about the systemd-devel
mailing list