[systemd-devel] DefaultDependencies of [Unit]

Christian Seiler christian at iwakd.de
Tue Apr 28 04:48:21 PDT 2015


Am 2015-04-28 11:33, schrieb Lennart Poettering:
> On Tue, 28.04.15 16:19, 樊超 (fcvidos at gmail.com) wrote:
>> I want to let my service run when shutdown,and it needn't close by
>> systemd,so can i set the DefaultDependencies of [Unit] to "no"?
>> I don't understand the meaning of DefaultDependencies.
>> It's [Unit] like this:
>> After=network.target network-online.target remote-fs.target
>> And I want to know if it matters when start the pc if I set
>> DefaultDependencies of [Unit] to "no"
>
> Sure it matters. If DefaultDependencies=yes you get ordered after
> basic.target and are shut down before shutdown.target is
> reached. If you set DefaultDependencies=no you are started really
> really early on (unless you explicitly order yourself after
> basic.target). That means you'd have to make sure your service is
> written in a way it can handle being run that early and doesn't 
> assume
> directories like /var are already mounted, or specific other services
> already running. Similar, during shutdown if you continue to access
> /var this late you will keep the mount for it busy, and accessing
> other services might fail earlier than expected.

On the other hand, nothing prevents somebody from adding back select
dependencies by hand, i.e. if only Conflicts=shutdown.target is what
is to be avoided, then using DefaultDependencies=no but also
After=basic.target will make sure the service isn't started too
early (but kept until systemd's final process killing spree).

Christian



More information about the systemd-devel mailing list