[ https://issues.apache.org/jira/browse/NIFI-2063?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15341861#comment-15341861 ]
Joseph Witt commented on NIFI-2063: ----------------------------------- Ryan H via nifi.apache.org (sent by ryan.andrew.hendrick...@gmail.com) 10:21 AM (0 minutes ago) to dev 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 > Install Script Relative Path Mismatch from Init Dir > --------------------------------------------------- > > Key: NIFI-2063 > URL: https://issues.apache.org/jira/browse/NIFI-2063 > Project: Apache NiFi > Issue Type: Bug > Components: Configuration > Affects Versions: 1.0.0, 0.7.0 > Environment: Linux/Unix with SysVInit > Reporter: James Wing > Fix For: 0.7.0 > > > Ryan Hendrickson noticed that installing and running NiFi as a service in > 0.7.0-SNAPSHOT is not working right. Running commands like the following: > {code} > $ sudo /opt/nifi/nifi-0.7.0-SNAPSHOT/bin/nifi.sh install > Service nifi installed > $ sudo service nifi start > /etc/init.d/nifi: line 28: /etc/init.d/nifi-env.sh: No such file or directory > {code} > Results in errors loading nifi-env.sh > *Used-To-Be* > As I understand it, {{nifi.sh install}} used to: > 1. copy bin/nifi.sh to /etc/init.d/nifi > 2. Run sed to change NIFI_HOME initializations to the path to nifi.sh, where > install was invoked > 3. When {{service nifi start}} was run, the NIFI_HOME path was hard-coded in > the service script file. > *As-Is* > 1. nifi.sh now gets NIFI_HOME from bin/nifi-env.sh, which is stored alongside > nifi.sh. > 2. install() still calls sed to update NIFI_HOME=, but the initialization is > now in nifi-env.sh, so nothing is replaced. > 3. When {{service nifi start}} is called, relative path to > {{SCRIPT_DIR/nifi-env.sh}} resolves to {{/etc/init.d/nifi-env.sh}}, which > does not exist. > *To-Be* > A possible solution might be to have sed update SCRIPT_DIR to be hard-coded, > and change to that directory to run nifi-env.sh. -- This message was sent by Atlassian JIRA (v6.3.4#6332)