wabbit
wabbit

Reputation: 143

Will systemd block system startup if daemon does not fork?

If I configure a systemd service in a way that type is set to "forking" and TimeoutStartSec is set to "infinity" then would my system startup block if the service configured never goes into background?

If not, what are the side effects of having such a configuration?

Upvotes: 0

Views: 169

Answers (1)

Alexis Wilke
Alexis Wilke

Reputation: 20720

The systemd implementation was to replace the SYS-V which already was getting a parallel startup by specifying dependencies instead of a simple priority (order defined by a two digit number such as 05-service and 67-daemon). But the SYS-V was not constrained in any way, so most processes would not really be properly defined. (The priority system was a filename and the dependencies were defined in a comment at the start of your init script).

systemd drew heavily from that concept of starting things in parallel by implementing a make like mechanism where you can say to build B only once A is built.

# Makefile
B: A
        generate-B

A: A.c
        gcc -o A A.c

So systemd in general won't be blocked because of one rogue service, however, if you now create a second service (i.e. B in my make example) which depends on that service which never returns as expected, that second service will never be started. i.e.

# Makefile
B: A
        generate-B      [never reach since A never ends]

A: A.c
        sleep forever

In other words, since your OS doesn't depend on your service, it will still load as expected. Your environment, however, is going to be affected if you start creating dependencies on your first services. On the other hand, there are probably various types of failsafe to circumvent, at least partially, the kind of setup you are talking about.

Upvotes: 2

Related Questions