socket_fd = -1;
}
- release_dependencies();
+ if (required_by == 0) {
+ // Service is now completely inactive.
+ release_dependencies();
+ }
}
}
sr->handle_exit_status();
}
+bool ServiceRecord::do_auto_restart() noexcept
+{
+ if (auto_restart) {
+ return service_set->get_auto_restart();
+ }
+ return false;
+}
+
void ServiceRecord::handle_exit_status() noexcept
{
if (exit_status != 0 && service_state != ServiceState::STOPPING) {
}
if (need_stop) {
+ if (! do_auto_restart()) desired_state = ServiceState::STOPPED;
do_stop();
}
return;
}
else {
+ if (! do_auto_restart()) desired_state = ServiceState::STOPPED;
forceStop();
}
}
to->require();
}
- if (service_state != ServiceState::STOPPED) {
+ if (service_state == ServiceState::STOPPED) {
+ // (In any other state, the service is already considered active.)
service_set->service_active(this);
}
}
{
if (desired_state == ServiceState::STOPPED && service_state != ServiceState::STARTED) return;
+ desired_state = ServiceState::STOPPED;
+
if (start_explicit) {
start_explicit = false;
release();
// Release console (console must be currently held by this service)
void releaseConsole() noexcept;
+ bool do_auto_restart() noexcept;
+
public:
ServiceRecord(ServiceSet *set, string name)