using namespace std;
ServiceRecord *record = loadServiceRecord(name);
- record->start(false);
+ record->start();
}
void ServiceSet::stopService(const std::string & name) noexcept
ServiceRecord * to = i->getTo();
to->require();
}
+
+ if (service_state != ServiceState::STOPPED) {
+ service_set->service_active(this);
+ }
}
}
service_set->service_inactive(this);
}
-void ServiceRecord::start(bool transitive) noexcept
+void ServiceRecord::start(bool activate) noexcept
{
- if ((service_state == ServiceState::STARTING || service_state == ServiceState::STARTED)
- && desired_state == ServiceState::STOPPED) {
- // This service was starting, or started, but was set to be stopped.
- // Cancel the stop (and continue starting/running).
- notifyListeners(ServiceEvent::STOPCANCELLED);
- }
-
- if (!transitive) {
+ if (activate) {
if (!start_explicit) require();
start_explicit = true;
}
if (desired_state == ServiceState::STARTED && service_state != ServiceState::STOPPED) return;
desired_state = ServiceState::STARTED;
- service_set->service_active(this);
do_start();
}
if ((*i)->service_state != ServiceState::STARTED) {
if (start_deps) {
all_deps_started = false;
- (*i)->start(true);
+ (*i)->start(false);
}
else {
return false;
ServiceRecord * to = i->getTo();
if (start_deps) {
if (to->service_state != ServiceState::STARTED) {
- to->start(true);
+ to->start(false);
i->waiting_on = true;
all_deps_started = false;
}
for (sr_iter i = dependents.begin(); i != dependents.end(); ++i) {
if (! (*i)->is_stopped()) {
all_deps_stopped = false;
- if (force_stop) {
- (*i)->forceStop();
- }
- else {
- (*i)->do_stop();
- }
+ }
+ if (force_stop) {
+ (*i)->forceStop();
+ }
+ else {
+ (*i)->do_stop();
}
}
void ServiceRecord::pinStart() noexcept
{
- start(false);
+ start(true);
pinned_started = true;
}
const char *getServiceName() const noexcept { return service_name.c_str(); }
ServiceState getState() const noexcept { return service_state; }
- void start(bool transitive = false) noexcept; // start the service
+ void start(bool activate = true) noexcept; // start the service
void stop() noexcept; // stop the service
void forceStop() noexcept; // force-stop this service and all dependents