markap14 commented on a change in pull request #4748:
URL: https://github.com/apache/nifi/pull/4748#discussion_r563786001



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-runtime/src/main/java/org/apache/nifi/BootstrapListener.java
##########
@@ -215,6 +220,12 @@ public void run() {
 
                                         
writeDiagnostics(socket.getOutputStream(), verbose);
                                         break;
+                                    case IS_LOADED:
+                                        logger.info("Received IS_LOADED 
request from Bootstrap");

Review comment:
       We should probably make this a DEBUG log. Since this is happening every 
2 seconds, we don't really want to see it constantly in the logs.

##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh
##########
@@ -345,6 +359,31 @@ run() {
 
     if [ "$1" = "start" ]; then
         ( eval "cd ${NIFI_HOME} && ${run_nifi_cmd}" & )> /dev/null 1>&-
+
+        if [ "$2" = "--wait-for-init" ]; then
+
+            declare -i wait_timeout
+            if is_nonzero_integer "$3" ; then
+                wait_timeout="$3"
+            else
+                wait_timeout=$WAIT_FOR_INIT_DEFAULT_TIMEOUT
+            fi
+
+            declare -i starttime=$(date +%s)
+            declare -i endtime=$starttime+$wait_timeout
+            declare -i current_time
+
+            is_nifi_loaded="false"
+            while [ "$is_nifi_loaded" = "false" ]; do
+                current_time=$(date +%s)
+                if (( current_time >= endtime )); then
+                  echo "Exited the script due to --wait-for-init timeout"
+                  break;
+                fi
+                is_nifi_loaded=$( eval "cd ${NIFI_HOME} && 
${run_bootstrap_cmd} is_loaded" )

Review comment:
       If NiFi takes a while to load, the user experience can leave the use 
wondering if anything is happening, or if something is 'stuck', etc. Probably 
best to provide some feedback here. Perhaps just an `echo NiFi has not fully 
initialized yet....` type of thing. Perhaps not every 2 seconds though. Maybe 
every 5 iterations (10 seconds) or so would make sense?

##########
File path: nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java
##########
@@ -711,6 +716,25 @@ public void dump(final File dumpFile) throws IOException {
         makeRequest(DUMP_CMD, null, dumpFile, "thread dump");
     }
 
+    private boolean isNiFiFullyLoaded() throws IOException {
+        final Logger logger = defaultLogger;
+        final Integer port = getCurrentPort(logger);
+        if (port == null) {
+            logger.info("Apache NiFi is not currently running");

Review comment:
       If NiFi fails to start, we see this in the logs. However, the 
`--wait-for-init` results in this constantly running, logging this over and 
over. If we encounter a case where NiFi is not running, it should not continue 
waiting for it to initialize, since we know that it will never complete.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to