restart over the interval specified by restart-limit-interval (default of
10 seconds). Specify a value of 0 to disable the restart limit.
+stop-timeout = XXX.YYYY
+ Specifies the time in seconds allowed for the service to stop. If the
+ service takes longer than this, its process group is sent a SIGKILL signal
+ which should cause it to terminate immediately. The timeout period begins
+ only when all dependent services have already stopped. The default stop
+ timeout is 10 seconds.
+
pid-file = (path to file)
For "bgprocess" type services only; specifies the path of the file where
daemon will write its process ID before detaching.
over the interval specified by \fBrestart-limit-interval\fR. Specify a value
of 0 to disable the restart limit.
.TP
+\fBstop-timeout\fR = \fIXXX.YYY\fR
+Specifies the time in seconds allowed for the service to stop. If the
+service takes longer than this, its process group is sent a SIGKILL signal
+which should cause it to terminate immediately. The timeout period begins
+only when all dependent services have already stopped. The default
+timeout is 10 seconds. Specify a value of 0 to allow unlimited stop time.
+.TP
\fBpid-file\fR = \fIpath-to-file\fR
For \fBbgprocess\fR type services only; specifies the path of the file where
daemon will write its process ID before detaching. Dinit will read the
timespec restart_interval = { .tv_sec = 10, .tv_nsec = 0 };
int max_restarts = 3;
timespec restart_delay = { .tv_sec = 0, .tv_nsec = 200000000 };
+ timespec stop_timeout = { .tv_sec = 10, .tv_nsec = 0 };
string line;
ifstream service_file;
string limit_str = read_setting_value(i, end, nullptr);
max_restarts = parse_unum_param(limit_str, name, std::numeric_limits<int>::max());
}
+ else if (setting == "stop-timeout") {
+ string stoptimeout_str = read_setting_value(i, end, nullptr);
+ parse_timespec(stoptimeout_str, name, "stop-timeout", stop_timeout);
+ }
else {
throw service_description_exc(name, "Unknown setting: " + setting);
}
command_offsets, std::move(depends_on), depends_soft);
rvalps->set_restart_interval(restart_interval, max_restarts);
rvalps->set_restart_delay(restart_delay);
+ rvalps->set_stop_timeout(stop_timeout);
rval = rvalps;
}
else if (service_type == service_type::BGPROCESS) {
rvalps->set_pid_file(std::move(pid_file));
rvalps->set_restart_interval(restart_interval, max_restarts);
rvalps->set_restart_delay(restart_delay);
+ rvalps->set_stop_timeout(stop_timeout);
rval = rvalps;
}
else if (service_type == service_type::SCRIPTED) {
- rval = new scripted_service(this, string(name), std::move(command),
+ auto rvalps = new scripted_service(this, string(name), std::move(command),
command_offsets, std::move(depends_on), depends_soft);
- rval->setStopCommand(stop_command, stop_command_offsets);
+ rvalps->setStopCommand(stop_command, stop_command_offsets);
+ rvalps->set_stop_timeout(stop_timeout);
+ rval = rvalps;
}
else {
rval = new service_record(this, string(name), service_type,
class base_process_service;
-// A timer for process restarting. Used to ensure a minimum delay between
-// process restarts.
+// A timer for process restarting. Used to ensure a minimum delay between process restarts (and
+// also for timing service stop before the SIGKILL hammer is used).
class process_restart_timer : public eventloop_t::timer_impl<process_restart_timer>
{
public:
{
restart_delay = delay;
}
+
+ void set_stop_timeout(timespec timeout) noexcept
+ {
+ stop_timeout = timeout;
+ }
};
class process_service : public base_process_service