[systemd-devel] GuessMainPID=no required to make daemon reload work

Lennart Poettering lennart at poettering.net
Mon May 5 08:27:41 PDT 2014


On Sun, 04.05.14 23:19, Gerd v. Egidy (lists at egidy.de) wrote:

> [Unit]
> Description=Icinga host/service/network monitoring system
> After=syslog.target postgresql.service mariadb.service

No need to mention "syslog.target" here anymore, this is actually
implied, as any systemd service is now started with logging available.

> 
> [Service]
> Type=forking
> EnvironmentFile=/etc/sysconfig/icinga2

This is a Fedoraism/Redhatism, I can only recommend not adding something
like this to upstream projects.

> ExecStart=/usr/sbin/icinga2 -c ${ICINGA2_CONFIG_FILE} -d -e ${ICINGA2_ERROR_LOG} -u ${ICINGA2_USER} -g ${ICINGA2_GROUP}

I'd recommend teaching the daemon to find its own config file when none
is specified and read the rest of the parameters from there...

> ExecReload=/bin/sh -c '/bin/kill -HUP `cat 
> ${ICINGA2_STATE_DIR}/run/icinga2/icinga2.pid`'

This is suboptimal. First of all, you should just tell systemd what the
PID file is, with $PIDFile, and then you can use $MAINPID to refer to
the PID. Secondly, the killing is asynchronous. It's a much better idea
to have some scheme in place that makes sure the process invoked by
ExecReload= does not return before the reload is complete, so that this
is race-free and can be used to order things against each other...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list