}
}
- will_restart &= (desired_state == ServiceState::STARTED);
for (auto dependency : depends_on) {
// we signal dependencies in case they are waiting for us to stop - but only if we won't
// restart or if they are stopping uninterruptibly.
if (will_restart) {
// Desired state is "started".
+ restarting = true;
service_set->addToStartQueue(this);
}
else {
bool base_process_service::start_ps_process() noexcept
{
- eventLoop.get_time(last_start_time, clock_type::MONOTONIC);
- return start_ps_process(exec_arg_parts, onstart_flags.runs_on_console);
+ if (restarting) {
+ restart_ps_process();
+ return true;
+ }
+ else {
+ return start_ps_process(exec_arg_parts, onstart_flags.runs_on_console);
+ }
}
bool base_process_service::start_ps_process(const std::vector<const char *> &cmd, bool on_console) noexcept
// exec closes the pipe, and the parent sees EOF. If the exec is unsuccessful, the errno
// is written to the pipe, and the parent can read it.
+ eventLoop.get_time(last_start_time, clock_type::MONOTONIC);
+
int pipefd[2];
if (pipe2(pipefd, O_CLOEXEC)) {
log(LogLevel::ERROR, service_name, ": can't create status check pipe: ", strerror(errno));
if (tdiff_s > 0 || tdiff_ns > 200000000) {
// > 200ms
- start_ps_process();
+ restarting = false;
+ if (! start_ps_process(exec_arg_parts, onstart_flags.runs_on_console)) {
+ // TODO handle appropriately; mark service stopped.
+ }
}
else {
timespec timeout;
dasynq::rearm base_process_service::restart_timer_expired() noexcept
{
// begin starting process:
- start_ps_process();
+ if (! start_ps_process(exec_arg_parts, onstart_flags.runs_on_console)) {
+ // TODO handle appropriately; mark service stopped.
+ }
return dasynq::rearm::DISARM;
}
bool prop_require : 1; // require must be propagated
bool prop_release : 1; // release must be propagated
bool prop_failure : 1; // failure to start must be propagated
+ bool restarting : 1; // re-starting after unexpected termination
int required_by = 0; // number of dependents wanting this service to be started
pinned_stopped(false), pinned_started(false), waiting_for_deps(false),
waiting_for_execstat(false), start_explicit(false),
prop_require(false), prop_release(false), prop_failure(false),
- force_stop(false)
+ restarting(false), force_stop(false)
{
service_set = set;
service_name = name;