I'm trying to get the 0.7.0 NiFi to start on boot on linux/centos 7.
During all this, I've noticed 0.6.1 doesn't quite work either, left some
notes at the bottom about that.
*For 0.7.0:*
*I followed the modified install commands for the nifi.sh script:*
I untar'd it in:
#/opt/nifi/current -> nifi-0.7.0-SNAPSHOT
I followed these steps:
##Edited the nifi.sh script for the SCRIPT_DIR issue.
#/opt/nifi/current/bin/nifi.sh install
*#chkconfig nifi on <--- Turn on for boot 2345 run levels*
#service nifi start
NiFi is now started.
I reboot the box.
*NiFi does not start.* There's no logs in /var/log/messages or
/opt/nifi/current/logs indicating why. (This script should probably log
someplace)
*Why?*
The current script has a command that starts as:
#cd ${NIFI_HOME} && sudo -u ${run_as} <rest-of-command> &
The sudo part is omitted if there is no ${run_as} user defined. This works
for starting the service by hand. However, if this script is set to start
on boot with a ${run_as} user, in this case using chkconfig, it will
silently fail when starting on boot because of the "sudo" part. Not sure
why "sudo" isn't well liked in CentOS 7 in a service script.
*How we fixed it:*
Fixed by structuring the command like this the nifi.sh script like this:
Old Command:
## RUN_NIFI_CMD="cd "\""${NIFI_HOME}"\"" && ${sudo_cmd_prefix}
"\""${JAVA}"\"" -cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m
${BOOTSTRAP_DIR_PARAMS} org.apache.nifi.bootstrap.RunNiFi"
Put it into the if's:
#if [ "$1" = "start" ]; then
# RUN_NIFI_CMD="su -c "\""cd "\""${NIFI_HOME}"\"" && "\""${JAVA}"\""
-cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS}
org.apache.nifi.bootstrap.RunNiFi $@ &"\"" ${run_as}"
# (eval $RUN_NIFI_CMD)
#else
# RUN_NIFI_CMD="su -c "\""cd "\""${NIFI_HOME}"\"" && "\""${JAVA}"\""
-cp "\""${BOOTSTRAP_CLASSPATH}"\"" -Xms12m -Xmx24m ${BOOTSTRAP_DIR_PARAMS}
org.apache.nifi.bootstrap.RunNiFi $@"\"" ${run_as}"
# (eval $RUN_NIFI_CMD)
#fi
It now starts on boot.
----------------------------------------
*Logging in this file:*
* I created a /var/log/nifi dir as root
* I started piping echo statements to "tee -a /var/log/nifi/init.log"
** *Example: #echo "Attempting to start NiFi" | tee -a
/var/log/nifi/init.log
----------------------------------------
*For 0.6.1:*
*I followed the standard install commands for the nifi.sh script.*
I untar'd it in:
#/opt/nifi/current -> nifi-0.7.0-SNAPSHOT
I followed these steps:
#/opt/nifi/current/bin/nifi.sh install
*#chkconfig nifi on <--- Turn on for boot 2345 run levels*
#service nifi start
NiFi is now started.
I reboot the box.
*NiFi does not start.* There's no logs in /var/log/messages or
/opt/nifi/current/logs indicating why. (This script should probably log
someplace)
*Why?*
The current script has a command that starts as:
#cd ${NIFI_HOME} && sudo -u ${run_as} <rest-of-command> &
The sudo part is omitted if there is no ${run_as} user defined. This works
for starting the service by hand. However, if this script is set to start
on boot with a ${run_as} user, in this case using chkconfig, it will
silently fail when starting on boot because of the "sudo" part. Not sure
why "sudo" isn't well liked in CentOS 7 in a service script.
*How we fixed it:*
Fixed by structuring the command like this:
#su -c "cd ${NIFI_HOME} && <rest-of-command> &" ${run_as}
This works when starting on boot if you have a ${run_as} user defined,
though not sure of the behavior if there is no ${run_as} user defined or if
the ${run_as} user is root.
--------------------------------------------------
Thanks,
Ryan