[systemd-devel] Shutdown a specific service in systemd shutdown

Bao Nguyen baondt at gmail.com
Wed May 25 06:59:48 UTC 2016


Hi,

Thanks for all your comments.

How do you think if we create a custom target to include all remaining
services, then add this target to the dependency After= of the specific
services. This way can make the specific stop before the services in the
target when the system shutdowns?

Thanks,
BRs,
Natsu

On Mon, May 23, 2016 at 3:54 PM, Lennart Poettering <lennart at poettering.net>
wrote:

> On Sun, 22.05.16 15:24, Andrei Borzenkov (arvidjaar at gmail.com) wrote:
>
> > 19.05.2016 11:57, Martin Pitt пишет:
> > > Hello Bao,
> > >
> > > Bao Nguyen [2016-05-19 15:52 +0700]:
> > >> When the system is shutdown, systemd will terminate all services in
> > >> parallel manner, could you let me know if there is any ways to tell
> systemd
> > >> to shutdown a specific service first, then shutdown all remaining
> services?
> > >
> > > The concept of "first"/"last" has no well-defined meaning in any
> > > non-serial init systems (not even SysV init with insserv, only with
> > > classic SysV init with manually set priorities). I've heard requests
> > > like "but this needs to be started as the last thing" a lot in the
> > > recent years, and there's no way all the services can simultaneously
> > > be "last" :-)
> >
> > Well, the very good example of service that has to be started/stopped
> > before/after anything else is splash screen (plymouth or anything). It
> > really must appear as soon as user hit ENTER in "systemctl reboot". As
> > it stands now, there is no way to ensure it.
>
> Well, shutting down is asynchronous anyway. Hence, yes, it should be shown
> pretty quickly, but strict, enforced ordering here is not necessary.
>
> This is a different story if you want a smooth transition between some
> graphical login thingy (such as gdm) and the ply shutdown screen, but
> in that case there should really be a direct hand-over so that gdm
> only releases the DRM when it knows that py has taken over. Such logic
> needs to happen directly between ply and gdm however, and in fact does
> already.
>
> > > You should put sufficient After= properties into your service, so that
> > > it gets started after and stopped before the ones you specify.
> >
> > Do you suggest adding dependency on plymouth to *every* service?
>
> No, I'd suggest that you are using the wrong tool here and should use
> something else...
>
> Lennart
>
> --
> Lennart Poettering, Red Hat
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160525/bc54007e/attachment.html>


More information about the systemd-devel mailing list