Commit Graph

108 Commits

Author SHA1 Message Date
Alexander Aleksandrovič Klimov 58e329bc03
Merge pull request #7874 from Icinga/feature/sd_notify-7329
sd_notify() systemd about what we're doing right now
2021-06-28 18:20:15 +02:00
Julian Brost 36ce7d961f Rename silent parameter of ConfigItem::ActivateItems()
As silent now no longer only controls the generation of log messages, a better
name is required. This changes its name, inverts its value to reflect the new
name and adds a documentation comment.
2021-06-21 16:07:36 +02:00
Alexander A. Klimov f0c763465b sd_notify() systemd about what we're doing right now
refs #7329
2021-06-01 18:07:39 +02:00
Julian Brost 54a8c7b434 Try to log useful information for exceptions thrown by RunWorker 2021-02-05 15:43:27 +01:00
Julian Brost d7833a5977 Catch exceptions thrown by RunWorker on Windows
The same is already done on other platforms in line 529.
2021-01-27 15:48:28 +01:00
Alexander Aleksandrovič Klimov 986bedd9a0
Merge pull request #8594 from Icinga/feature/remove-upq-from-activate-items
Remove upq from ConfigItem::ActivateItems
2021-01-15 12:09:57 +01:00
Alexander A. Klimov 931b9307ae StartUnixWorker(): don't exit() on fork() failure
... but let the caller handle the failure.

Not to stop working completely just because of fork() failure during a reload.
2021-01-14 13:40:18 +01:00
Julian Brost 0c6abc817b Remove upq from ConfigItem::ActivateItems
Since commit d9010c7b9f, ActivateItems no
longer uses the WorkQueue upq to perform tasks but instead performs
these locally. One instance of `upq.Join()`/`upq.HasExceptions()`
remained in the function, but I believe this was just missed when
removing the `upq.Enqueue()` call just before.

This commit removes the corresponding parameter and updates all call
sites accordingly.
2021-01-13 15:19:55 +01:00
Alexander Aleksandrovič Klimov d996d1e201
Merge pull request #8580 from bebehei/typo
Fix typo seemless -> seamless
2021-01-11 13:45:08 +01:00
Benedikt Heine 8a455e8150 Fix typo seemless -> seamless 2020-12-25 23:27:08 +01:00
Alexander A. Klimov 8c6bfdcf54 Revert "icinga2 daemon: reap remaining child processes after reload"
This reverts commit 91265a5b0e
which isn't needed anymore as Icinga 2 isn't PID 1 anymore.
2020-12-14 13:38:35 +01:00
Alexander Aleksandrovič Klimov 4926353269
Merge pull request #8277 from Icinga/bugfix/latency-8196
Call Process::InitializeSpawnHelper() ASAP
2020-10-16 16:49:06 +02:00
Alexander Aleksandrovič Klimov d6a4db935f
Merge pull request #8374 from Icinga/bugfix/docker-memory-leak
icinga2 daemon: reap remaining child processes after reload
2020-10-16 10:33:49 +02:00
Alexander Aleksandrovič Klimov 1f55338cbd
Merge pull request #8166 from Icinga/bugfix/logrotate-crash-8050
Ensure the daemon doesn't get killed by logrotate
2020-10-15 10:39:47 +02:00
Alexander A. Klimov 91265a5b0e icinga2 daemon: reap remaining child processes after reload
... as we may be PID 1.
2020-10-15 10:25:14 +02:00
Alexander A. Klimov d3f6a97a7e Ensure the daemon doesn't get killed by logrotate
refs #8050
2020-10-14 14:02:44 +02:00
Alexander A. Klimov 177f930375 Call Process::InitializeSpawnHelper() ASAP
refs #8196
2020-09-23 11:49:13 +02:00
Michael Friedrich 5812dae55b Dev: Allow to delay main worker process in order to attach with LLDB
Introduce `-DInternal.DebugWorkerDelay=120` and sleep inside `RunWorker()`.

Rationale: With 2.11 we've introduced a real umbrella process where the
main process is spawned as child fork. Running icinga2 in foreground on
a macOS shell with LLDB will now exit, and not follow the child process.

LLDB doesn't support `follow-fork-mode child` like GDB and therefore we
need to:

- Print the child process PID
- Sleep for X seconds to allow the developer to run `lldb -p <PID>`, set breakpoints, etc.

This commit also documents all available debug build enabled internal constants.
2020-01-29 13:21:05 +01:00
Stuart Henderson 6744b1af54 cope with OS which don't fill in si_pid in siginfo
Icinga processes check si_pid on IPC signals to ensure that the signal
comes from an expected process. OpenBSD doesn't currently fill in si_pid
in siginfo (leaving it 0) so signals never pass this check, resulting
in startup failing to complete (the worker doesn't see the umbrella's
signal and vice-versa) - issue #7505.

Relax the requirement so that either 0 or the wanted pid is accepted.
2020-01-07 22:08:38 +00:00
Michael Friedrich 9d6ee44e71
Merge pull request #7346 from Icinga/feature/check-plugins-code-page-7110
DaemonCommand#Run(): set code page to UTF-8
2019-08-27 14:51:30 +02:00
Michael Friedrich 01fe243f23 Log a hint after failed config validation for systemd users 2019-08-07 12:03:17 +02:00
Alexander A. Klimov 6418c2ebb7 icinga2 daemon --close-stdio: keep console log open during first config validation
refs #7394
2019-08-05 18:30:45 +02:00
Alexander A. Klimov d7e52824c8 DaemonCommand#Run(): set code page to UTF-8
refs #7110
2019-07-19 18:00:46 +02:00
Alexander A. Klimov 31e5394fe9 Fix style
refs #5230
2019-07-16 11:45:23 +02:00
Alexander A. Klimov c385355c38 DaemonCommand: make the atomics a bit more atomic
Just to be sure.

refs #5230
2019-07-16 11:39:09 +02:00
Alexander A. Klimov 4ee9ac16b4 Fix missing comments
refs #5230
2019-07-16 11:11:10 +02:00
Alexander A. Klimov 372ecd8a72 Forward SIGUSR1
refs #5230
2019-07-15 18:36:34 +02:00
Alexander A. Klimov 3584ad97d8 Fix missing log messages
refs #5230
2019-07-15 18:29:15 +02:00
Alexander A. Klimov ac29b3b93a Adjust sd_notify()
refs #5230
2019-07-15 17:04:55 +02:00
Alexander A. Klimov 06b504f291 Adjust PID file management
refs #5230
2019-07-15 17:04:53 +02:00
Alexander A. Klimov 368ebf4fbf Catch programming errors
refs #5230
2019-07-15 15:24:07 +02:00
Alexander A. Klimov 37a3e7e4d5 Application::RunEventLoop(): forward restart requests to umbrella process
refs #5230
2019-07-15 15:23:37 +02:00
Alexander A. Klimov 249408209d Reload on SIGHUP
refs #5230
2019-07-15 15:23:34 +02:00
Alexander A. Klimov c303d08c24 Do the actual work in a separate process on *nix
refs #5230
2019-07-15 15:18:31 +02:00
Alexander A. Klimov d6bc5a1a18 Remove old signal handlers
refs #5230
2019-07-15 15:06:29 +02:00
Michael Friedrich c77d6eb869 Quality: Drop unused boost/tuple header include 2019-05-24 15:50:43 +02:00
Michael Friedrich 6cce9c0fdd API: Automatically repair broken packages
This partially reverts #7150 and avoids exceptions
inside the flow. Each time an empty active stage
is detected, Icinga tries to repair it from the
the given directory tree.

Also, the code now takes into account that it should
create the package storage on startup, whether within
the API object, or if disabled, inside the application.

Caching the active stages for packages in memory
only is in effect with the API feature being enabled.
This is useful for other deployed config packages,
not only the internal one.

fixes #7173
refs #7150
refs #7119
fixes #6959
2019-05-10 12:48:34 +02:00
Michael Friedrich 0d6d48fd59 Daemon: Deal with exceptions from broken _api package 2019-04-26 14:43:10 +02:00
Michael Friedrich d14a88235d Replace Copyright header with a short version, part I
CLion -> replace in path
2019-02-25 14:48:22 +01:00
Michael Friedrich dab53448bc icinga.com: Update *.{h,c}pp 2018-10-18 09:27:04 +02:00
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
Alan Jenkins 50463a6a10 Daemonize(): use one error convention, not three
Standardize on exit() / _exit() (this depends whether we are considered
to be the "main" fork, which should run anything registered with atexit()).
Exclude `return false` and throwing exceptions.

This fixes the error path for fork().  Daemonize() would return false, but
the `return false` error convention was not tested in the caller.

It also fixes the error message for fork() to show the error code.
Everyone loves `strace`, but sysadmins should not have to rerun their
daemons under it just to see an error code.

Also in case an exception is thrown, show its diagnostic information
instead of dropping it on the floor.  In the log message, I mention why we
are uninitializing and then initializing the app at this point.

For the reader, it pushes all the weirdness into the error convention of
Daemonize().  This comes back to the exit() / _exit() distinction.  Once
we have forked, we technically don't want to allow the parent process to
exit(), so we don't want to return to the caller.
2018-08-25 10:07:02 +01:00
Gunnar Beutner e678fa1aa5 Refactor Application::*Const() 2018-08-13 15:27:05 +02:00
Michael Friedrich a2a1f5c8d2 Take a note why the explicit configDir variable is needed on Windows 2018-08-07 18:33:59 +02:00
Markus Frosch 9fbc40615a Improve path handling in cmake and daemon 2018-08-07 14:10:26 +02:00
Michael Friedrich 7519d23892 Add debug logging for daemonize/timers
The previous commit is 1:1 the same I've implemented
here already. Great teamwork with Alex :)

refs #6445
2018-07-19 13:34:12 +02:00
Jean Flach 9a5d464448 Revert "Fix Windows reload"
This reverts commit 691e3cfd57.
2018-06-12 12:19:16 +02:00
Michael Friedrich e606a443b7 Add support for config validation log timestamps
This also adds implicit support for the startup.log
generated from API config package validation, e.g. used by
the Icinga Director.

fixes #3455
2018-05-03 11:35:29 +02:00
Jean Flach a742e64e4d Fix reload handling
Make sure we have written the new PID before letting it take over.
2018-03-14 10:43:59 +01:00
Jean Flach 691e3cfd57 Fix Windows reload 2018-02-23 17:01:46 +01:00