Hello Many apologies that there hasn't been any follow up. Can you please turn this into a JIRA if this is still an issue.
Thanks Joe On Wed, Jun 22, 2016 at 3:38 PM, Nicholas Hughes <nicholasmhughes.n...@gmail.com> wrote: > Ryan, > > I ran into a similar issue, in that our security policies generally don't > allow sudo for much... even for the root account in an init script. I > didn't want to hack up the nifi.sh script too much, so I just popped out a > quick systemd unit file: > > [Unit] > Description=Apache NiFi > After=syslog.target network.target > > [Service] > User=nifi > Type=simple > ExecStart=/bin/java -cp /opt/nifi/conf/:/opt/nifi/lib/bootstrap/* -Xms12m > -Xmx24m > -Dorg.apache.nifi.bootstrap.config.file=/opt/nifi/conf/bootstrap.conf > org.apache.nifi.bootstrap.RunNiFi start > ExecStop=/bin/java -cp /opt/nifi/conf/:/opt/nifi/lib/bootstrap/* -Xms12m > -Xmx24m > -Dorg.apache.nifi.bootstrap.config.file=/opt/nifi/conf/bootstrap.conf > org.apache.nifi.bootstrap.RunNiFi stop > Restart=always > RestartSec=360 > > [Install] > WantedBy=multi-user.target > > > Paths may have to be changed depending on your installation. It's not too > fancy, but it seems to work just fine for EL7. > > -Nick > > > On Tue, Jun 21, 2016 at 10:21 AM, Ryan H <rhendrickson.w...@gmail.com> > wrote: > >> 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 >>