void base_process_service::do_restart() noexcept
{
restarting = false;
+ waiting_restart_timer = false;
// We may be STARTING (regular restart) or STARTED ("smooth recovery"). This affects whether
// the process should be granted access to the console:
else {
timespec timeout = diff_time(restart_delay, tdiff);
restart_timer.arm_timer_rel(eventLoop, timeout);
+ waiting_restart_timer = true;
}
return true;
}
+void base_process_service::interrupt_start() noexcept
+{
+ // overridden in subclasses
+ if (waiting_restart_timer) {
+ restart_timer.stop_timer(eventLoop);
+ waiting_restart_timer = false;
+ }
+}
+
dasynq::rearm process_restart_timer::timer_expiry(EventLoop_t &, int expiry_count)
{
service->do_restart();
// Whether a STARTING service can immediately transition to STOPPED (as opposed to
// having to wait for it reach STARTED and then go through STOPPING).
- bool can_interrupt_start() noexcept
+ virtual bool can_interrupt_start() noexcept
{
return waiting_for_deps;
}
+ virtual void interrupt_start() noexcept
+ {
+ // overridden in subclasses
+ }
+
// Whether a STOPPING service can immediately transition to STARTED.
bool can_interrupt_stop() noexcept
{
int max_restart_interval_count;
timespec restart_delay;
+ bool waiting_restart_timer = false;
+
// Start the process, return true on success
- virtual bool start_ps_process() noexcept;
+ virtual bool start_ps_process() noexcept override;
bool start_ps_process(const std::vector<const char *> &args, bool on_console) noexcept;
// Restart the process (due to start failure or unexpected termination). Restarts will be
// rate-limited.
bool restart_ps_process() noexcept;
- virtual void all_deps_stopped() noexcept;
+ virtual void all_deps_stopped() noexcept override;
virtual void handle_exit_status(int exit_status) noexcept = 0;
+ virtual bool can_interrupt_start() noexcept override
+ {
+ return waiting_restart_timer || ServiceRecord::can_interrupt_start();
+ }
+
+ virtual void interrupt_start() noexcept override;
+
public:
base_process_service(ServiceSet *sset, string name, ServiceType service_type, string &&command,
std::list<std::pair<unsigned,unsigned>> &command_offsets,
{
}
- void set_restart_interval(timespec interval, int max_restarts)
+ void set_restart_interval(timespec interval, int max_restarts) noexcept
{
restart_interval = interval;
max_restart_interval_count = max_restarts;
}
- void set_restart_delay(timespec delay)
+ void set_restart_delay(timespec delay) noexcept
{
restart_delay = delay;
}