core: let user define start-/stop-timeout behaviour
The usual behaviour when a timeout expires is to terminate/kill the service. This is what user usually want in production systems. To debug services that fail to start/stop (especially sporadic failures) it might be necessary to trigger the watchdog machinery and write core dumps, though. Likewise, it is usually just a waste of time to gracefully stop a stuck service. Instead it might save time to go directly into kill mode. This commit adds two new options to services: TimeoutStartFailureMode= and TimeoutStopFailureMode=. Both take the same values and tweak the behavior of systemd when a start/stop timeout expires: * 'terminate': is the default behaviour as it has always been, * 'abort': triggers the watchdog machinery and will send SIGABRT (unless WatchdogSignal was changed) and * 'kill' will directly send SIGKILL. To handle the stop failure mode in stop-post state too a new final-watchdog state needs to be introduced.
This commit is contained in:
committed by
Lennart Poettering
parent
8b5616fa91
commit
bf76080180
@@ -74,6 +74,14 @@ typedef enum ServiceResult {
|
||||
_SERVICE_RESULT_INVALID = -1
|
||||
} ServiceResult;
|
||||
|
||||
typedef enum ServiceTimeoutFailureMode {
|
||||
SERVICE_TIMEOUT_TERMINATE,
|
||||
SERVICE_TIMEOUT_ABORT,
|
||||
SERVICE_TIMEOUT_KILL,
|
||||
_SERVICE_TIMEOUT_FAILURE_MODE_MAX,
|
||||
_SERVICE_TIMEOUT_FAILURE_MODE_INVALID = -1
|
||||
} ServiceTimeoutFailureMode;
|
||||
|
||||
struct ServiceFDStore {
|
||||
Service *service;
|
||||
|
||||
@@ -103,6 +111,8 @@ struct Service {
|
||||
usec_t timeout_abort_usec;
|
||||
bool timeout_abort_set;
|
||||
usec_t runtime_max_usec;
|
||||
ServiceTimeoutFailureMode timeout_start_failure_mode;
|
||||
ServiceTimeoutFailureMode timeout_stop_failure_mode;
|
||||
|
||||
dual_timestamp watchdog_timestamp;
|
||||
usec_t watchdog_usec; /* the requested watchdog timeout in the unit file */
|
||||
@@ -228,6 +238,9 @@ NotifyState notify_state_from_string(const char *s) _pure_;
|
||||
const char* service_result_to_string(ServiceResult i) _const_;
|
||||
ServiceResult service_result_from_string(const char *s) _pure_;
|
||||
|
||||
const char* service_timeout_failure_mode_to_string(ServiceTimeoutFailureMode i) _const_;
|
||||
ServiceTimeoutFailureMode service_timeout_failure_mode_from_string(const char *s) _pure_;
|
||||
|
||||
DEFINE_CAST(SERVICE, Service);
|
||||
|
||||
#define STATUS_TEXT_MAX (16U*1024U)
|
||||
|
||||
Reference in New Issue
Block a user