On Fri, 12.02.16 11:48, Viraj Raiyani ([email protected]) wrote: > Hi All, > > > > I wanted to start a service before the networking service comes up and I > found out that you need to add dependency on network-pre.target as Before > and Wants in your service file. However, doing so resulted in killing the > networking service as my service unit was implicitly adding dependency on > basic.target resulting in a loop. > > After doing more research I found DefaultDependency=no removes the > dependency on basic.target and it does not create a cycle. However, adding > DefaultDependency=no introduces other problems such as pre-mature start of > my service when some of the system needed services are not up. > > Is there a way to add dependency on network-pre.target and don’t add > DefaultDependency=no in the unit without killing the networking service?
If you you want your network to be up in early boot, then evreything you order before it needs to run in early boot. That's a logical requirement. To get something to run in early boot you have to set DefaultDependencies=no, there's no way around that. Now, if you do that, then your service needs to be prepared for this way of operatin (i.e. no regular system services are connectible, not everything mounted yet, /var or /tmp not accessible or only accessible read-only). You'll be started very early on, but you have some control over that: for example, you could order yourself after local-fs.target in case you want all local file systems to be around. But be careful, you can create cyclic dep loops this way. Long story short: if you want to run in early boot you need to be careful what you do and know what you do. Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/systemd-devel
