diff options
author | Benjamin Berg <bberg@redhat.com> | 2019-12-13 14:12:38 +0100 |
---|---|---|
committer | Benjamin Berg <benjamin@sipsolutions.net> | 2020-07-31 08:54:40 +0000 |
commit | 54137921bff67829f47e0b5d778fd9fba227b7e2 (patch) | |
tree | effa3b16553a454dada1183e57101072a3931528 | |
parent | bd02b91408a41609c3a6e76c9af0a1fd91e74e9f (diff) | |
download | gnome-session-54137921bff67829f47e0b5d778fd9fba227b7e2.tar.gz |
gnome-session-ctl: Add systemd service failure checker
This is intended to be run from core components of a session. It is an
alternative to using OnFailure=gnome-session-failed.target that can be
put into ExecStopPost/ExecStop which will only trigger OnFailure for a
subset of errors.
Primarily this avoids trigger the OnFailure action for dependency
issues.
-rw-r--r-- | tools/gnome-session-ctl.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/gnome-session-ctl.c b/tools/gnome-session-ctl.c index 86f03be1..8d94f844 100644 --- a/tools/gnome-session-ctl.c +++ b/tools/gnome-session-ctl.c @@ -238,6 +238,7 @@ main (int argc, char *argv[]) static gboolean opt_monitor; static gboolean opt_signal_init; static gboolean opt_restart_dbus; + static gboolean opt_exec_stop_check; int conflicting_options; GOptionContext *ctx; static const GOptionEntry options[] = { @@ -245,6 +246,7 @@ main (int argc, char *argv[]) { "monitor", '\0', 0, G_OPTION_ARG_NONE, &opt_monitor, N_("Start gnome-session-shutdown.target when receiving EOF or a single byte on stdin"), NULL }, { "signal-init", '\0', 0, G_OPTION_ARG_NONE, &opt_signal_init, N_("Signal initialization done to gnome-session"), NULL }, { "restart-dbus", '\0', 0, G_OPTION_ARG_NONE, &opt_restart_dbus, N_("Restart dbus.service if it is running"), NULL }, + { "exec-stop-check", '\0', 0, G_OPTION_ARG_NONE, &opt_exec_stop_check, N_("Run from ExecStopPost to start gnome-session-failed.target on service failure"), NULL }, { NULL }, }; @@ -271,6 +273,8 @@ main (int argc, char *argv[]) conflicting_options++; if (opt_restart_dbus) conflicting_options++; + if (opt_exec_stop_check) + conflicting_options++; if (conflicting_options != 1) { g_printerr (_("Program needs exactly one parameter")); exit (1); @@ -287,6 +291,11 @@ main (int argc, char *argv[]) } else if (opt_monitor) { do_monitor_leader (); do_start_unit ("gnome-session-shutdown.target", "replace-irreversibly"); + } else if (opt_exec_stop_check) { + /* Start failed target if the restart limit was hit */ + if (g_strcmp0 ("start-limit-hit", g_getenv ("SERVICE_RESULT")) == 0) { + do_start_unit ("gnome-session-failed.target", "fail"); + } } else { g_assert_not_reached (); } |