diff options
author | Tom Cherry <tomcherry@google.com> | 2019-09-10 10:40:47 -0700 |
---|---|---|
committer | Tobias Thierer <tobiast@google.com> | 2019-09-13 16:48:35 +0100 |
commit | 60971e6ce22bd4fee531dc72875acb4b913f69a7 (patch) | |
tree | aa80b358efb90ac48551640a81e29dc0d52aefad /init/builtins.cpp | |
parent | 6f735df0d1268cc976e5834c3cb1cc9e6fe9395d (diff) |
init: add reboot_on_failure service option
This replaces the recently added `exec_reboot_on_failure` builtin, since
it'll be cleaner to extend service definitions than extending `exec`.
This is in line with what we decided when adding `exec_start` instead
of extending `exec` to add parameters for priority.
Test: `exec_start` a service with a reboot_on_failure option and watch
the system reboot appropriately when the service is not found and when
the service terminates with a non-zero exit code.
Change-Id: I332bf9839fa94840d159a810c4a6ba2522189d0b
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 21db8dca7..42211b2c1 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -1104,20 +1104,6 @@ static Result<void> ExecWithFunctionOnFailure(const std::vector<std::string>& ar return {}; } -static Result<void> do_exec_reboot_on_failure(const BuiltinArguments& args) { - auto reboot_reason = args[1]; - auto reboot = [reboot_reason](const std::string& message) { - property_set(LAST_REBOOT_REASON_PROPERTY, reboot_reason); - sync(); - LOG(FATAL) << message << ": rebooting into bootloader, reason: " << reboot_reason; - }; - - std::vector<std::string> remaining_args(args.begin() + 1, args.end()); - remaining_args[0] = args[0]; - - return ExecWithFunctionOnFailure(remaining_args, reboot); -} - static Result<void> ExecVdcRebootOnFailure(const std::string& vdc_arg) { auto reboot_reason = vdc_arg + "_failed"; @@ -1225,7 +1211,6 @@ const BuiltinFunctionMap& GetBuiltinFunctionMap() { {"enable", {1, 1, {false, do_enable}}}, {"exec", {1, kMax, {false, do_exec}}}, {"exec_background", {1, kMax, {false, do_exec_background}}}, - {"exec_reboot_on_failure", {2, kMax, {false, do_exec_reboot_on_failure}}}, {"exec_start", {1, 1, {false, do_exec_start}}}, {"export", {2, 2, {false, do_export}}}, {"hostname", {1, 1, {true, do_hostname}}}, |