From: Davin McCall Date: Thu, 7 Jun 2018 17:38:10 +0000 (+0100) Subject: Avoid logging service stop after failure to start. X-Git-Tag: v0.2.0~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=12b59dd7694a5b38d1d0af88ac233807aed18c68;p=oweals%2Fdinit.git Avoid logging service stop after failure to start. The "FAILED" followed by "STOPPED" is somewhat redundant and arguably incorrect. --- diff --git a/src/includes/service.h b/src/includes/service.h index d907b09..fabe302 100644 --- a/src/includes/service.h +++ b/src/includes/service.h @@ -285,6 +285,7 @@ class service_record bool prop_stop : 1; bool restarting : 1; // re-starting after unexpected termination + bool start_failed : 1; // failed to start (reset when begins starting) int required_by = 0; // number of dependents wanting this service to be started @@ -456,7 +457,8 @@ class service_record pinned_stopped(false), pinned_started(false), waiting_for_deps(false), waiting_for_console(false), have_console(false), waiting_for_execstat(false), start_explicit(false), prop_require(false), prop_release(false), prop_failure(false), - prop_start(false), prop_stop(false), restarting(false), force_stop(false) + prop_start(false), prop_stop(false), restarting(false), start_failed(false), + force_stop(false) { services = set; service_name = name; diff --git a/src/service.cc b/src/service.cc index 7c87cd0..40060a7 100644 --- a/src/service.cc +++ b/src/service.cc @@ -104,7 +104,10 @@ void service_record::stopped() noexcept } } - log_service_stopped(service_name); + // Start failure will have been logged already, only log if we are stopped for other reasons: + if (! start_failed) { + log_service_stopped(service_name); + } notify_listeners(service_event_t::STOPPED); } @@ -188,6 +191,7 @@ void service_record::start(bool activate) noexcept services->service_active(this); } + start_failed = false; service_state = service_state_t::STARTING; waiting_for_deps = true; @@ -412,6 +416,7 @@ void service_record::failed_to_start(bool depfailed, bool immediate_stop) noexce } } + start_failed = true; log_service_failed(get_name()); notify_listeners(service_event_t::FAILEDSTART);