diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-09-14 16:41:30 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-09-14 16:41:30 +0200 |
commit | 4e6dd0ecf51eb30f54794299598dfbd60d527a79 (patch) | |
tree | 2accd60d8cae76fd5096d75918e4efe95f665544 /node-admin | |
parent | 6b5b1af7039b65ae2f297ae134579cb841116876 (diff) |
Support not waiting for termination of command
Diffstat (limited to 'node-admin')
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java index d86c8745ceb..95b76c4b93a 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/process/CommandLine.java @@ -59,6 +59,7 @@ public class CommandLine { private Duration sigTermGracePeriod = DEFAULT_SIGTERM_GRACE_PERIOD; private Duration sigKillGracePeriod = DEFAULT_SIGKILL_GRACE_PERIOD; private Predicate<Integer> successfulExitCodePredicate = code -> code == 0; + private boolean waitForTermination = true; public CommandLine(TaskContext taskContext, ProcessFactory processFactory) { this.taskContext = taskContext; @@ -242,6 +243,11 @@ public class CommandLine { return this; } + public CommandLine doNotWaitForTermination() { + this.waitForTermination = false; + return this; + } + public List<String> getArguments() { return Collections.unmodifiableList(arguments); } // Accessor fields necessary for classes in this package. Could be public if necessary. @@ -256,6 +262,12 @@ public class CommandLine { private CommandResult doExecute() { try (ChildProcess2 child = processFactory.spawn(this)) { + if (!waitForTermination) { + // WARNING: This will leave the child as a zombie process until this process dies. + // I.e. only use this just before or a limited number of times per host admin restart. + return new CommandResult(this, 0, ""); + } + child.waitForTermination(); int exitCode = child.exitCode(); if (!successfulExitCodePredicate.test(exitCode)) { |