From 4e335c17e50a6bce4897c602484f7337acc3bd3c Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 12 Jan 2016 00:58:55 +0000 Subject: [PATCH] During shutdown, let process attrition occur naturally, instead of forcing the services down early. Also, don't restart a service which has desired_state = STARTED if auto-restart is disabled. --- src/service.cc | 5 +++-- src/service.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/service.cc b/src/service.cc index 2be1d21..f810b04 100644 --- a/src/service.cc +++ b/src/service.cc @@ -74,7 +74,7 @@ void ServiceRecord::stopped() noexcept dependency->dependentStopped(); } - if (desired_state == ServiceState::STARTED) { + if (desired_state == ServiceState::STARTED && service_set->get_auto_restart()) { // Desired state is "started". do_start(); } @@ -144,7 +144,8 @@ void ServiceRecord::handle_exit_status() noexcept } if (need_stop) { - if (! do_auto_restart()) desired_state = ServiceState::STOPPED; + // Failed startup: no auto-restart. + desired_state = ServiceState::STOPPED; do_stop(); } diff --git a/src/service.h b/src/service.h index 1817db4..64ae15c 100644 --- a/src/service.h +++ b/src/service.h @@ -545,7 +545,7 @@ class ServiceSet restart_enabled = false; shutdown_type = type; for (std::list::iterator i = records.begin(); i != records.end(); ++i) { - (*i)->stop(); + (*i)->stop(false); (*i)->unpin(); } } -- 2.25.1