2014-05-01 01:48:01 +02:00
|
|
|
[Unit]
|
2014-06-24 02:15:35 +02:00
|
|
|
Description=Icinga host/service/network monitoring system
|
2018-11-09 13:17:08 +01:00
|
|
|
Requires=network-online.target
|
2017-04-04 09:27:19 +02:00
|
|
|
After=syslog.target network-online.target postgresql.service mariadb.service carbon-cache.service carbon-relay.service
|
2014-05-01 01:48:01 +02:00
|
|
|
|
|
|
|
[Service]
|
2018-01-17 13:52:23 +01:00
|
|
|
Type=notify
|
2018-11-13 14:02:03 +01:00
|
|
|
Environment="ICINGA2_ERROR_LOG=@ICINGA2_LOGDIR@/error.log"
|
2014-06-15 19:47:27 +02:00
|
|
|
EnvironmentFile=@ICINGA2_SYSCONFIGFILE@
|
2018-07-17 09:59:59 +02:00
|
|
|
ExecStartPre=@CMAKE_INSTALL_PREFIX@/lib/icinga2/prepare-dirs @ICINGA2_SYSCONFIGFILE@
|
Fix logging under systemd
icinga2.service used `-e ${ICINGA2_ERROR_LOG}`, but this is documented
as having no effect without `-d`. Furthermore, icinga2 under systemd
unconditionally logged everything to the system log (but without setting
the log level etc), which contradicted the documentation. (Issue #6339)
Stop icinga2 on systemd from logging to stdout - and hence the system log -
once it has finished starting up. Just like when you start icinga2 from a
terminal using `-d`. And just like -d, we stop logging fatal errors to
stderr, and instead write to the log file passed with `-e`.
As per docs, mainlog (icinga2.log) is already enabled by default. And
pre-startup messages including config errors will still appear in the
system log.
This uses a new option --close-stdio, which has the same effect on logging as
--daemonize, but does not fork or call setsid().
For this purpose, I moved setsid() up and into Daemonize().
Consequence of that last point: if anyone is weird enough to specify a TTY
device file as the fatal error log (-e option), that will become icinga's
controlling terminal, which you generally don't want as a daemon. This
makes it consistent with the existing behaviour for icinga mainlog. For
this reason you're supposed to use O_NOCTTY in Linux daemons. But I wasn't
sure where icinga would want to put the ugly `#ifdef _WIN32 ... #else ...`.
2018-05-29 18:24:05 +02:00
|
|
|
ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 daemon --close-stdio -e ${ICINGA2_ERROR_LOG}
|
2018-07-31 11:59:09 +02:00
|
|
|
PIDFile=@ICINGA2_INITRUNDIR@/icinga2.pid
|
2018-07-17 09:59:59 +02:00
|
|
|
ExecReload=@CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload @ICINGA2_SYSCONFIGFILE@
|
2016-07-27 07:44:11 +02:00
|
|
|
TimeoutStartSec=30m
|
2017-09-23 15:16:00 +02:00
|
|
|
|
|
|
|
# Systemd >228 enforces a lower process number for services.
|
|
|
|
# Depending on the distribution and Systemd version, this must
|
|
|
|
# be explicitly raised. Packages will set the needed values
|
|
|
|
# into /etc/systemd/system/icinga2.service.d/limits.conf
|
|
|
|
#
|
|
|
|
# Please check the troubleshooting documentation for further details.
|
|
|
|
# The values below can be used as examples for customized service files.
|
|
|
|
|
|
|
|
#TasksMax=infinity
|
|
|
|
#LimitNPROC=62883
|
2014-05-01 01:48:01 +02:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|