icinga2/lib/cli
Alan Jenkins a21166dcf8 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-08-25 10:21:06 +01:00
..
CMakeLists.txt Remove ApiUser password_hash functionality 2018-06-19 11:32:03 +02:00
apisetupcommand.cpp Revert "Implement support for the --env command-line argument" 2018-07-26 17:09:06 +02:00
apisetupcommand.hpp Revert "Implement support for the --env command-line argument" 2018-07-26 17:09:06 +02:00
apisetuputility.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
apisetuputility.hpp Revert "Implement support for the --env command-line argument" 2018-07-26 17:09:06 +02:00
calistcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
calistcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
casigncommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
casigncommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
clicommand.cpp Fix program option parsing 2018-06-12 19:02:48 +02:00
clicommand.hpp Remove unused includes 2018-01-22 09:52:29 +01:00
consolecommand.cpp Merge pull request #5979 from Icinga/feature/enhance-console-5595 2018-01-29 16:41:10 +01:00
consolecommand.hpp Apply clang-tidy fix 'modernize-pass-by-value' 2018-01-04 12:24:57 +01:00
daemoncommand.cpp Fix logging under systemd 2018-08-25 10:21:06 +01:00
daemoncommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
daemonutility.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
daemonutility.hpp Build libraries as static libraries 2018-01-02 23:29:48 +01:00
editline.hpp Change copyright header for 2018 2018-01-02 12:08:55 +01:00
featuredisablecommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
featuredisablecommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
featureenablecommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
featureenablecommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
featurelistcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
featurelistcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
featureutility.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
featureutility.hpp Revert "Implement support for the --env command-line argument" 2018-07-26 17:09:06 +02:00
i2-cli.hpp Build libraries as static libraries 2018-01-02 23:29:48 +01:00
internalsignalcommand.cpp Add cli tool to send signals as Icinga user 2018-02-20 14:16:43 +01:00
internalsignalcommand.hpp Add cli tool to send signals as Icinga user 2018-02-20 14:16:43 +01:00
nodesetupcommand.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
nodesetupcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
nodeutility.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
nodeutility.hpp Fix style and logging from review; enhance output 2018-05-08 16:59:09 +02:00
nodewizardcommand.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
nodewizardcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
objectlistcommand.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
objectlistcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
objectlistutility.cpp Change copyright header for 2018 2018-01-02 12:08:55 +01:00
objectlistutility.hpp Build libraries as static libraries 2018-01-02 23:29:48 +01:00
pkinewcacommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
pkinewcacommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
pkinewcertcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
pkinewcertcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
pkirequestcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
pkirequestcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
pkisavecertcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
pkisavecertcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
pkisigncsrcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
pkisigncsrcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
pkiticketcommand.cpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
pkiticketcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
troubleshootcommand.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
troubleshootcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
variablegetcommand.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
variablegetcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
variablelistcommand.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
variablelistcommand.hpp Apply clang-tidy fix 'modernize-use-override' 2018-01-04 12:24:57 +01:00
variableutility.cpp Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
variableutility.hpp Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00