From 8d467f3d1fe9b9e96e67f2979aa5676465afedc1 Mon Sep 17 00:00:00 2001 From: Koji Kawamura Date: Tue, 21 Feb 2017 15:41:51 +0900 Subject: [PATCH] NIFI-3505: Fix nifi.sh restart The 'exec' command added by NIFI-2689 affected restart behavior negatively as 'exec' command will not execute subsequent commands in the shell script. This commit changes 'exec' is added only when 'run' is specified. This closes #1523. Signed-off-by: Aldrin Piri --- .../nifi-resources/src/main/resources/bin/nifi.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 8834cbc43b..d827735bab 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 @@ -286,12 +286,19 @@ run() { BOOTSTRAP_CONF_PARAMS="-Dorg.apache.nifi.bootstrap.config.file='${BOOTSTRAP_CONF}'" BOOTSTRAP_DIR_PARAMS="${BOOTSTRAP_LOG_PARAMS} ${BOOTSTRAP_PID_PARAMS} ${BOOTSTRAP_CONF_PARAMS}" - run_nifi_cmd="exec '${JAVA}' -cp '${BOOTSTRAP_CLASSPATH}' -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi $@" + + run_nifi_cmd="'${JAVA}' -cp '${BOOTSTRAP_CLASSPATH}' -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi $@" + if [ -n "${run_as_user}" ]; then # Provide SCRIPT_DIR and execute nifi-env for the run.as user command run_nifi_cmd="sudo -u ${run_as_user} sh -c \"SCRIPT_DIR='${SCRIPT_DIR}' && . '${SCRIPT_DIR}/nifi-env.sh' && ${run_nifi_cmd}\"" fi + if [ "$1" = "run" ]; then + # Use exec to handover PID to RunNiFi java process, instead of foking it as a child process + run_nifi_cmd="exec ${run_nifi_cmd}" + fi + if [ "$1" = "start" ]; then ( eval "cd ${NIFI_HOME} && ${run_nifi_cmd}" & ) else