Repository: nifi
Updated Branches:
  refs/heads/master 9aa9c27db -> 0609a84fa


NIFI-1059: If we get an IOException when telling NiFi to shutdown, just kill 
NiFi immediately, instead of giving up

Signed-off-by: joewitt <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/757202b6
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/757202b6
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/757202b6

Branch: refs/heads/master
Commit: 757202b63e98ca0e9b60ca811f48054b0b4cefc7
Parents: 9aa9c27
Author: Mark Payne <[email protected]>
Authored: Wed Nov 25 16:21:58 2015 -0500
Committer: joewitt <[email protected]>
Committed: Thu Nov 26 01:03:53 2015 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/nifi/bootstrap/RunNiFi.java  | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/757202b6/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 c8d1f4d..a3d3de7 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
@@ -627,13 +627,14 @@ public class RunNiFi {
 
         final Properties nifiProps = loadProperties(logger);
         final String secretKey = nifiProps.getProperty("secret.key");
+        final String pid = nifiProps.getProperty("pid");
 
         try (final Socket socket = new Socket()) {
             logger.debug("Connecting to NiFi instance");
-            socket.setSoTimeout(60000);
+            socket.setSoTimeout(10000);
             socket.connect(new InetSocketAddress("localhost", port));
             logger.debug("Established connection to NiFi instance.");
-            socket.setSoTimeout(60000);
+            socket.setSoTimeout(10000);
 
             logger.debug("Sending SHUTDOWN Command to port {}", port);
             final OutputStream out = socket.getOutputStream();
@@ -654,7 +655,6 @@ public class RunNiFi {
             if (SHUTDOWN_CMD.equals(response)) {
                 logger.info("Apache NiFi has accepted the Shutdown Command and 
is shutting down now");
 
-                final String pid = nifiProps.getProperty("pid");
                 if (pid != null) {
                     final Properties bootstrapProperties = new Properties();
                     try (final FileInputStream fis = new 
FileInputStream(bootstrapConfigFile)) {
@@ -703,7 +703,13 @@ public class RunNiFi {
                 logger.error("When sending SHUTDOWN command to NiFi, got 
unexpected response {}", response);
             }
         } catch (final IOException ioe) {
-            logger.error("Failed to send shutdown command to port {} due to 
{}", new Object[]{port, ioe.toString(), ioe});
+            if (pid == null) {
+                logger.error("Failed to send shutdown command to port {} due 
to {}. No PID found for the NiFi process, so unable to kill process; "
+                    + "the process should be killed manually.", new Object[] 
{port, ioe.toString(), ioe});
+            } else {
+                logger.error("Failed to send shutdown command to port {} due 
to {}. Will kill the NiFi Process with PID {}.", new Object[] {port, 
ioe.toString(), ioe, pid});
+                killProcessTree(pid, logger);
+            }
         } finally {
             if (lockFile.exists() && !lockFile.delete()) {
                 logger.error("Failed to delete lock file {}; this file should 
be cleaned up manually", lockFile);

Reply via email to