}
else if (pid != -1) {
// Starting, start timed out.
- log(loglevel_t::WARN, "Service ", get_name(), " with pid ", pid, " exceeded allowed start time.");
- stop_dependents();
- if (start_explicit) {
- start_explicit = false;
- release();
- }
+ log(loglevel_t::WARN, "Service ", get_name(), " with pid ", pid, " exceeded allowed start time; cancelling.");
interrupt_start();
+ failed_to_start(false, false);
}
else {
// STARTING / STARTED, and we have a pid: must be restarting (smooth recovery if STARTED)
// Service failed to start (only called when in STARTING state).
// dep_failed: whether failure is recorded due to a dependency failing
- void failed_to_start(bool dep_failed = false) noexcept;
+ // immediate_stop: whether to set state as STOPPED and handle complete stop.
+ void failed_to_start(bool dep_failed = false, bool immediate_stop = true) noexcept;
// Run a child process (call after forking).
// - args specifies the program arguments including the executable (argv[0])
}
}
-void service_record::failed_to_start(bool depfailed) noexcept
+void service_record::failed_to_start(bool depfailed, bool immediate_stop) noexcept
{
- if (have_console) {
- bp_sys::tcsetpgrp(0, bp_sys::getpgrp());
- release_console();
+ if (immediate_stop) {
+ service_state = service_state_t::STOPPED;
+ if (have_console) {
+ bp_sys::tcsetpgrp(0, bp_sys::getpgrp());
+ release_console();
+ }
}
+
if (waiting_for_console) {
services->unqueue_console(this);
waiting_for_console = false;
}
- log_service_failed(get_name());
- service_state = service_state_t::STOPPED;
if (start_explicit) {
start_explicit = false;
release(false);
}
- notify_listeners(service_event_t::FAILEDSTART);
// Cancel start of dependents:
for (auto & dept : dependents) {
}
}
}
+
+ log_service_failed(get_name());
+ notify_listeners(service_event_t::FAILEDSTART);
}
bool service_record::bring_up() noexcept
bool service_record::interrupt_start() noexcept
{
- if (onstart_flags.starts_on_console) {
- services->unqueue_console(this);
- }
return true;
}