Hi Michael, Thanks for your comments, looks like it will work. I will try it.
Just adding a question, if my specific is written in old style (SystemVinit), it has LSB header, how can I modify it to make it depend on multi-user.target. Thanks, Brs On Wed, May 25, 2016 at 5:09 PM, Michael Chapman <m...@very.puzzling.org> wrote: > On Thu, 19 May 2016, Bao Nguyen wrote: > >> Hi everyone, >> >> 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? >> > > Hello, > > I haven't tested it, but as far as I know all you need to do is ensure > your special service is After=multi-user.target, i.e.: > > [Unit] > Description=Some service that must be started late / stopped early > After=multi-user.target > > [Service] > # ... > > [Install] > WantedBy=multi-user.target > > A target unit is automatically After= all the units that it Wants=, > Requires=, etc., but this automatic dependency is *not* added if that would > create a dependency loop. > > So at shutdown systemd knows it needs to stop all services and targets. > Because your special service is After=multi-user.target, and > multi-user.target is After= all *other* normal services, everything gets > ordered correctly: your service is stopped first, then multi-user.target is > stopped, then all the other services are stopped. > > Now, this isn't the *cleanest* solution -- you really want to be specific > in your service dependencies rather than depending upon a whole target's > worth of services, and there's always the chance that multi-user.target > might be stopped some other way before shutdown -- but it does seem as if > it goes some way to solving your problem. > > - Michael >
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel