[systemd-devel] simple type service failed to be started won't effect the service requires it?

Han Pingtian hanpt at linux.vnet.ibm.com
Wed Jun 22 01:25:57 UTC 2016


On Tue, Jun 21, 2016 at 05:01:55PM +0200, Lennart Poettering wrote:
> On Tue, 21.06.16 22:22, Han Pingtian (hanpt at linux.vnet.ibm.com) wrote:
> 
> > Hi,
> > 
> > I have a service thinkfan.service:
> > 
> >     [Unit]
> >     Description=simple and lightweight fan control program
> >     After=syslog.target lm_sensors.service
> >     
> >     [Service]
> >     ExecStart=/usr/sbin/thinkfan -n ${OPTIONS}
> >     Type=simple
> >     PIDFile=/var/run/thinkfan.pid
> >     ExecReload=/bin/kill -HUP $MAINPID
> >     EnvironmentFile=/etc/sysconfig/thinkfan
> >     
> >     [Install]
> >     WantedBy=multi-user.target
> > 
> > And I have added "Requires=thinkfan.service" in another service
> > foo.service. Now there are some problems in thinkfan.service, it cannot
> > be started. But foo.service can be started by "systemctl start
> > foo.service" though I hope it would fail due to thinkfan.service's
> > failure. 
> > 
> > Now if I changed the "Type=simple" to "Type=forking" in thinkfan.service, 
> > and remove "-n" to make thinkfan running as a daemon, then foo.service 
> > will fail to be started.
> > 
> > Is this a problem? Thanks in advance!
> 
> This is by design. By using Type=forking you basically say: "fork this
> off, wait until it double forks and exits in the parent". By using
> Type=simple you basically say: "fork this off, don't wait for
> anything". Now in the former case the initialization phase of the
> daemon is waited for and can return an exit code. In the latter case
> that's not possible: nothing is waited for, and nothing can return an
> initialization exit code.
> 
> Hence, if you want that an error condition from the initialisation
> phase of a daemon shall have an effect on Requires= then you cannot
> use Type=simple on that service. use Type=forking then, or Type=notify
> or another type.

Thanks a lot, Lennart!



More information about the systemd-devel mailing list