[arch-general] Forking daemons and systemd

Tom Gundersen teg at jklm.no
Mon Nov 5 11:13:45 EST 2012

On Mon, Nov 5, 2012 at 5:01 PM, Leonid Isaev <lisaev at umail.iu.edu> wrote:
>         I was wondering whether there is a guideline regarding using
> Type=forking daemons in systemd units. For instance, if a daemon supports a
> cmdline switch to run in foreground isn't it better to use this argument in
> ExecStart?

If you start the daemon in the foreground (i.e., use the default
Type=simple), it means that systemd will consider it started
immediately, and not wait for it to be initialized. In other words, it
assumes that whatever communication channels (sockets) have been set
up already and that the daemon supports being socket activated. If
that is not the case, then services which are ordered after your
service might start too early.

Clearly, if you know that nothing will ever be ordered After= your
service the above is not an issue, and you can use Type=simple without

A better solution would be to patch the service to support
Type=dbus/notify or to support socket activation.

If that is out of the question, then Type=forking is the safest bet.
This mode is a bit more fragile than the other ones, as it relies on
systemd being able to figure out what is the main process. Specifying
PIDFile= is advised if the daemon supports that. Though it depends on
the daemon implementing that correctly. Most (all?) it works just fine



More information about the arch-general mailing list