From ff5330d7f27fefede59b804210741e845d39693f Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 1 Dec 2015 21:01:35 -0500 Subject: [PATCH] NIFI-1238: Ensure that if we timeout when communicating with NiFi and do a kill -9 that we also delete the status file; otherwise, the already-running bootstrap will restart nifi Signed-off-by: joewitt --- .../src/main/java/org/apache/nifi/bootstrap/RunNiFi.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 098be034dc..ea8127756b 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 @@ -628,6 +628,7 @@ public class RunNiFi { final Properties nifiProps = loadProperties(logger); final String secretKey = nifiProps.getProperty("secret.key"); final String pid = nifiProps.getProperty("pid"); + final File statusFile = getStatusFile(logger); try (final Socket socket = new Socket()) { logger.debug("Connecting to NiFi instance"); @@ -693,7 +694,6 @@ public class RunNiFi { } } - final File statusFile = getStatusFile(logger); if (statusFile.exists() && !statusFile.delete()) { logger.error("Failed to delete status file {}; this file should be cleaned up manually", statusFile); } @@ -708,7 +708,11 @@ public class RunNiFi { + "the process should be killed manually.", new Object[] {port, ioe.toString()}); } else { logger.error("Failed to send shutdown command to port {} due to {}. Will kill the NiFi Process with PID {}.", new Object[] {port, ioe.toString(), pid}); + notifyStop(); killProcessTree(pid, logger); + if (statusFile.exists() && !statusFile.delete()) { + logger.error("Failed to delete status file {}; this file should be cleaned up manually", statusFile); + } } } finally { if (lockFile.exists() && !lockFile.delete()) {