chiark / gitweb /
service: Implement 'on-watchdog' restart option
authorHannes Reinecke <hare@suse.de>
Thu, 25 Jul 2013 12:07:59 +0000 (14:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Sep 2013 16:29:44 +0000 (18:29 +0200)
Services using the watchdog option might want to be restarted
only if the watchdog triggers.

man/systemd.service.xml
src/core/service.c
src/core/service.h

index a15dfb2cb69876dec403fb4fa9fea087bc578f1d..1eb5f39628b3e21f58d374da6282b8b7003c806b 100644 (file)
                                 <option>no</option>,
                                 <option>on-success</option>,
                                 <option>on-failure</option>,
+                                <option>on-watchdog</option>,
                                 <option>on-abort</option>, or
                                 <option>always</option>. If set to
                                 <option>no</option> (the default) the
                                 signal not specified as a clean exit
                                 status.
                                 If set to
+                                <option>on-watchdog</option> the service
+                                will be restarted only if the watchdog
+                                timeout for the service expires.
+                                If set to
                                 <option>always</option> the service
                                 will be restarted regardless whether
                                 it exited cleanly or not, got
index 34dde7963e6fdd6d53b375ce37e1953f8004be82..08b929e4fe7af4b5ff4763c7177b9e13ef9f0460 100644 (file)
@@ -1937,6 +1937,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
             (s->restart == SERVICE_RESTART_ALWAYS ||
              (s->restart == SERVICE_RESTART_ON_SUCCESS && s->result == SERVICE_SUCCESS) ||
              (s->restart == SERVICE_RESTART_ON_FAILURE && s->result != SERVICE_SUCCESS) ||
+             (s->restart == SERVICE_RESTART_ON_WATCHDOG && s->result == SERVICE_FAILURE_WATCHDOG) ||
              (s->restart == SERVICE_RESTART_ON_ABORT && (s->result == SERVICE_FAILURE_SIGNAL ||
                                                          s->result == SERVICE_FAILURE_CORE_DUMP))) &&
             (s->result != SERVICE_FAILURE_EXIT_CODE ||
@@ -3791,6 +3792,7 @@ static const char* const service_restart_table[_SERVICE_RESTART_MAX] = {
         [SERVICE_RESTART_NO] = "no",
         [SERVICE_RESTART_ON_SUCCESS] = "on-success",
         [SERVICE_RESTART_ON_FAILURE] = "on-failure",
+        [SERVICE_RESTART_ON_WATCHDOG] = "on-watchdog",
         [SERVICE_RESTART_ON_ABORT] = "on-abort",
         [SERVICE_RESTART_ALWAYS] = "always"
 };
index 182cba1333673fd0edba91a286dda23949377e46..ce5b5e04ab1e02bcb67256200bedd5bc9ccb5112 100644 (file)
@@ -54,6 +54,7 @@ typedef enum ServiceRestart {
         SERVICE_RESTART_NO,
         SERVICE_RESTART_ON_SUCCESS,
         SERVICE_RESTART_ON_FAILURE,
+        SERVICE_RESTART_ON_WATCHDOG,
         SERVICE_RESTART_ON_ABORT,
         SERVICE_RESTART_ALWAYS,
         _SERVICE_RESTART_MAX,