stopped();
}
+void base_process_service::do_smooth_recovery() noexcept
+{
+ if (! restart_ps_process()) {
+ emergency_stop();
+ services->process_queues();
+ }
+}
+
void process_service::handle_exit_status(int exit_status) noexcept
{
bool did_exit = WIFEXITED(exit_status);
services->process_queues();
}
-void base_process_service::do_smooth_recovery() noexcept
+void process_service::exec_failed(int errcode) noexcept
{
- if (! restart_ps_process()) {
+ log(loglevel_t::ERROR, service_name, ": execution failed: ", strerror(errcode));
+ if (service_state == service_state_t::STARTING) {
+ failed_to_start();
+ }
+ else {
+ // Process service in smooth recovery:
emergency_stop();
- services->process_queues();
}
}
services->process_queues();
}
+void bgproc_service::exec_failed(int errcode) noexcept
+{
+ log(loglevel_t::ERROR, service_name, ": execution failed: ", strerror(errcode));
+ // Only time we execute is for startup:
+ failed_to_start();
+}
+
void scripted_service::handle_exit_status(int exit_status) noexcept
{
bool did_exit = WIFEXITED(exit_status);
}
}
+void scripted_service::exec_failed(int errcode) noexcept
+{
+ log(loglevel_t::ERROR, service_name, ": execution failed: ", strerror(errcode));
+ if (service_state == service_state_t::STARTING) {
+ failed_to_start();
+ }
+ else if (service_state == service_state_t::STOPPING) {
+ // We've logged the failure, but it's probably better not to leave the service in
+ // STOPPING state:
+ stopped();
+ }
+}
+
rearm exec_status_pipe_watcher::fd_event(eventloop_t &loop, int fd, int flags) noexcept
{
base_process_service *sr = service;
}
}
sr->pid = -1;
- log(loglevel_t::ERROR, sr->service_name, ": execution failed: ", strerror(exec_status));
- if (sr->service_state == service_state_t::STARTING) {
- sr->failed_to_start();
- }
- else if (sr->service_state == service_state_t::STOPPING) {
- // Must be a scripted service, or a regular process service that happened to be in smooth
- // recovery when the stop was issued.
- if (sr->record_type == service_type::PROCESS) {
- if (sr->stop_check_dependents()) {
- sr->stopped();
- }
- }
- else {
- // We've logged the failure, but it's probably better not to leave the service in
- // STOPPING state:
- sr->stopped();
- }
- }
- else if (sr->service_state == service_state_t::STARTED) {
- // Process service in smooth recovery:
- sr->emergency_stop();
- }
+ sr->exec_failed(exec_status);
}
else {
// exec() succeeded.
// Called when the process exits. The exit_status is the status value yielded by
// the "wait" system call.
virtual void handle_exit_status(int exit_status) noexcept = 0;
+ virtual void exec_failed(int errcode) noexcept = 0;
virtual bool can_interrupt_start() noexcept override
{
class process_service : public base_process_service
{
virtual void handle_exit_status(int exit_status) noexcept override;
+ virtual void exec_failed(int errcode) noexcept override;
virtual void all_deps_stopped() noexcept override;
public:
class bgproc_service : public base_process_service
{
virtual void handle_exit_status(int exit_status) noexcept override;
+ virtual void exec_failed(int errcode) noexcept override;
enum class pid_result_t {
OK,
class scripted_service : public base_process_service
{
- virtual void all_deps_stopped() noexcept override;
virtual void handle_exit_status(int exit_status) noexcept override;
+ virtual void exec_failed(int errcode) noexcept override;
+ virtual void all_deps_stopped() noexcept override;
public:
scripted_service(service_set *sset, string name, string &&command,