}
}
-void ServiceRecord::failed_to_start()
+void ServiceRecord::failed_to_start(bool depfailed) noexcept
{
- if (onstart_flags.runs_on_console) {
+ if (!depfailed && onstart_flags.runs_on_console) {
tcsetpgrp(0, getpgrp());
releaseConsole();
}
service_set->service_inactive(this);
notifyListeners(ServiceEvent::FAILEDSTART);
- // failure to start
// Cancel start of dependents:
for (sr_iter i = dependents.begin(); i != dependents.end(); i++) {
if ((*i)->service_state == ServiceState::STARTING) {
- (*i)->failed_dependency();
+ (*i)->failed_to_start(true);
}
}
for (auto i = soft_dpts.begin(); i != soft_dpts.end(); i++) {
}
}
-// A dependency of this service failed to start.
-// Only called when state == STARTING.
-void ServiceRecord::failed_dependency()
-{
- desired_state = ServiceState::STOPPED;
-
- // Presumably, we were starting. So now we're not.
- service_state = ServiceState::STOPPED;
- service_set->service_inactive(this);
- logServiceFailed(service_name);
-
- // Notify dependents of this service also
- for (auto i = dependents.begin(); i != dependents.end(); i++) {
- if ((*i)->service_state == ServiceState::STARTING) {
- (*i)->failed_dependency();
- }
- }
- for (auto i = soft_dpts.begin(); i != soft_dpts.end(); i++) {
- // It's a soft dependency, so send them 'started' rather than
- // 'failed dep'.
- (*i)->getFrom()->dependencyStarted();
- }
-}
-
void ServiceRecord::dependentStopped() noexcept
{
if (service_state == ServiceState::STOPPING) {
// Service has successfully started
void started() noexcept;
- // Service failed to start
- void failed_to_start();
-
- // A dependency of this service failed to start.
- void failed_dependency();
-
+ // 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;
+
// For process services, start the process, return true on success
bool start_ps_process() noexcept;
bool start_ps_process(const std::vector<const char *> &args, bool on_console) noexcept;