Module: check_mk
Branch: master
Commit: fc519a21c8a878af8e0175437c2621037d78fdac
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fc519a21c8a878…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Jul 13 10:49:09 2018 +0200
6227 FIX Fix failing termination or config reload
Change-Id: Ifb0b0e0a2aa49cc12c54bea618ccf7f4b6c756e2
---
.werks/6227 | 10 +++++++++
cmk/ec/main.py | 69 +++++++++++++++++++++++++++++-----------------------------
2 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/.werks/6227 b/.werks/6227
new file mode 100644
index 0000000..a4ee1a4
--- /dev/null
+++ b/.werks/6227
@@ -0,0 +1,10 @@
+Title: Fix failing termination or config reload
+Level: 2
+Component: ec
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1531469606
+
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 93a0386..0a0526e 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -3183,35 +3183,41 @@ def run_eventd(terminate_main_event, settings, config,
lock_configuration, histo
while not terminate_main_event.is_set():
try:
- # Wait until either housekeeping or retention is due, but at
- # maximum 60 seconds. That way changes of the interval from a very
- # high to a low value will never require more than 60 seconds
-
- event_list = [next_housekeeping, next_retention, next_statistics]
- if is_replication_slave(config):
- event_list.append(next_replication)
-
- time_left = max(0, min(event_list) - time.time())
- time.sleep(min(time_left, 60))
-
- now = time.time()
- if now > next_housekeeping:
- event_server.do_housekeeping()
- next_housekeeping = now + config["housekeeping_interval"]
-
- if now > next_retention:
- with event_status.lock:
- event_status.save_status()
- next_retention = now + config["retention_interval"]
-
- if now > next_statistics:
- perfcounters.do_statistics()
- next_statistics = now + config["statistics_interval"]
-
- # Beware: replication might be turned on during this loop!
- if is_replication_slave(config) and now > next_replication:
- replication_pull(settings, config, lock_configuration, perfcounters,
event_status, event_server, slave_status, logger)
- next_replication = now +
config["replication"]["interval"]
+ try:
+ # Wait until either housekeeping or retention is due, but at
+ # maximum 60 seconds. That way changes of the interval from a very
+ # high to a low value will never require more than 60 seconds
+
+ event_list = [next_housekeeping, next_retention, next_statistics]
+ if is_replication_slave(config):
+ event_list.append(next_replication)
+
+ time_left = max(0, min(event_list) - time.time())
+ time.sleep(min(time_left, 60))
+
+ now = time.time()
+ if now > next_housekeeping:
+ event_server.do_housekeeping()
+ next_housekeeping = now + config["housekeeping_interval"]
+
+ if now > next_retention:
+ with event_status.lock:
+ event_status.save_status()
+ next_retention = now + config["retention_interval"]
+
+ if now > next_statistics:
+ perfcounters.do_statistics()
+ next_statistics = now + config["statistics_interval"]
+
+ # Beware: replication might be turned on during this loop!
+ if is_replication_slave(config) and now > next_replication:
+ replication_pull(settings, config, lock_configuration, perfcounters,
event_status, event_server, slave_status, logger)
+ next_replication = now +
config["replication"]["interval"]
+ except Exception as e:
+ logger.exception("Exception in main thread:\n%s" % e)
+ if settings.options.debug:
+ raise
+ time.sleep(1)
except MKSignalException as e:
if e._signum == 1:
logger.info("Received SIGHUP - going to reload configuration")
@@ -3219,11 +3225,6 @@ def run_eventd(terminate_main_event, settings, config,
lock_configuration, histo
else:
logger.info("Signalled to death by signal %d" % e._signum)
terminate(terminate_main_event, event_server, status_server)
- except Exception as e:
- logger.exception("Exception in main thread:\n%s" % e)
- if settings.options.debug:
- raise
- time.sleep(1)
# Now wait for termination of the server threads
event_server.join()