Release on failure to start.
authorDavin McCall <davmac@davmac.org>
Mon, 6 Jun 2016 07:30:38 +0000 (08:30 +0100)
committerDavin McCall <davmac@davmac.org>
Mon, 6 Jun 2016 07:30:38 +0000 (08:30 +0100)
(Ensures dependencies will stop if they are not otherwise required).

src/service.cc

index 98de0e5834be9f34296733381335c9aa325f6c79..6900d4e464c330e83c134654878e06289c8f72b1 100644 (file)
@@ -122,7 +122,7 @@ bool ServiceRecord::do_auto_restart() noexcept
 
 void ServiceRecord::handle_exit_status() noexcept
 {
-    if (exit_status != 0 && service_state != ServiceState::STOPPING) {
+    if (service_type != ServiceType::SCRIPTED && exit_status != 0 && service_state != ServiceState::STOPPING) {
         log(LogLevel::ERROR, "Service ", service_name, " process terminated with exit code ", exit_status);
     }
 
@@ -186,7 +186,7 @@ void ServiceRecord::handle_exit_status() noexcept
             }
             else {
                 // ??? failed to stop! Let's log it as info:
-                log(LogLevel::INFO, "service ", service_name, " stop command failed with exit code ", exit_status);
+                log(LogLevel::INFO, "Service ", service_name, " stop command failed with exit code ", exit_status);
                 // Just assume that we stopped, so that any dependencies
                 // can be stopped:
                 stopped();
@@ -198,7 +198,7 @@ void ServiceRecord::handle_exit_status() noexcept
             }
             else {
                 // failed to start
-                log(LogLevel::ERROR, "service ", service_name, " command failed with exit code ", exit_status);
+                log(LogLevel::ERROR, "Service ", service_name, " command failed with exit code ", exit_status);
                 failed_to_start();
             }
         }
@@ -580,6 +580,7 @@ void ServiceRecord::failed_to_start(bool depfailed) noexcept
     
     logServiceFailed(service_name);
     service_state = ServiceState::STOPPED;
+    stop(); // release dependencies if appropriate
     notifyListeners(ServiceEvent::FAILEDSTART);
     
     // Cancel start of dependents: