Repository: nifi Updated Branches: refs/heads/master 231f5143a -> 99d3c3974
NIFI-1069 - improve init script exit codes so that results are LSB compliant This closes: #1093 Signed-off-by: Andre F de Miranda <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/99d3c397 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/99d3c397 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/99d3c397 Branch: refs/heads/master Commit: 99d3c397481a98a5b3d2d4e44b84516fc0e3675e Parents: 231f514 Author: Michal Klempa <[email protected]> Authored: Tue Oct 4 14:25:49 2016 +0200 Committer: Andre F de Miranda <[email protected]> Committed: Thu Oct 20 23:12:23 2016 +1100 ---------------------------------------------------------------------- .../main/java/org/apache/nifi/bootstrap/RunNiFi.java | 15 ++++++++++----- .../nifi-resources/src/main/resources/bin/nifi.sh | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/99d3c397/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java ---------------------------------------------------------------------- diff --git a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java index 04e7ba3..8d92c44 100644 --- a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java +++ b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java @@ -204,6 +204,7 @@ public class RunNiFi { final File configFile = getBootstrapConfFile(); final RunNiFi runNiFi = new RunNiFi(configFile, verbose); + Integer exitStatus = null; switch (cmd.toLowerCase()) { case "start": runNiFi.start(); @@ -215,7 +216,7 @@ public class RunNiFi { runNiFi.stop(); break; case "status": - runNiFi.status(); + exitStatus = runNiFi.status(); break; case "restart": runNiFi.stop(); @@ -228,6 +229,9 @@ public class RunNiFi { runNiFi.env(); break; } + if (exitStatus != null) { + System.exit(exitStatus); + } } private static File getBootstrapConfFile() { @@ -581,23 +585,23 @@ public class RunNiFi { return new Status(port, pid, pingSuccess, alive); } - public void status() throws IOException { + public int status() throws IOException { final Logger logger = cmdLogger; final Status status = getStatus(logger); if (status.isRespondingToPing()) { logger.info("Apache NiFi is currently running, listening to Bootstrap on port {}, PID={}", new Object[]{status.getPort(), status.getPid() == null ? "unknown" : status.getPid()}); - return; + return 0; } if (status.isProcessRunning()) { logger.info("Apache NiFi is running at PID {} but is not responding to ping requests", status.getPid()); - return; + return 4; } if (status.getPort() == null) { logger.info("Apache NiFi is not running"); - return; + return 3; } if (status.getPid() == null) { @@ -605,6 +609,7 @@ public class RunNiFi { } else { logger.info("Apache NiFi is not running"); } + return 3; } public void env() { http://git-wip-us.apache.org/repos/asf/nifi/blob/99d3c397/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh index ff8addd..7b471d7 100755 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh @@ -295,12 +295,14 @@ run() { else (eval $RUN_NIFI_CMD $@) fi + EXIT_STATUS=$? # Wait just a bit (3 secs) to wait for the logging to finish and then echo a new-line. # We do this to avoid having logs spewed on the console after running the command and then not giving # control back to the user sleep 3 echo + exit $EXIT_STATUS } main() {
