Github user iemejia commented on a diff in the pull request: https://github.com/apache/flink/pull/2239#discussion_r70873347 --- Diff: flink-dist/src/main/flink-bin/bin/flink-daemon.sh --- @@ -77,31 +77,36 @@ if [[ ${JAVA_VERSION} =~ ${IS_NUMBER} ]]; then fi case $STARTSTOP in + (start|start-foreground) + # Rotate log files + rotateLogFile $log + rotateLogFile $out + + # Print a warning if daemons are already running on host + if [ -f $pid ]; then + active=() + while IFS='' read -r p || [[ -n "$p" ]]; do + kill -0 $p >/dev/null 2>&1 + if [ $? -eq 0 ]; then + active+=($p) + fi + done < "${pid}" - (start) - # Rotate log files - rotateLogFile $log - rotateLogFile $out - - # Print a warning if daemons are already running on host - if [ -f $pid ]; then - active=() - while IFS='' read -r p || [[ -n "$p" ]]; do - kill -0 $p >/dev/null 2>&1 - if [ $? -eq 0 ]; then - active+=($p) - fi - done < "${pid}" - - count="${#active[@]}" + count="${#active[@]}" - if [ ${count} -gt 0 ]; then - echo "[INFO] $count instance(s) of $DAEMON are already running on $HOSTNAME." - fi + if [ ${count} -gt 0 ]; then + echo "[INFO] $count instance(s) of $DAEMON are already running on $HOSTNAME." fi + fi + + if [[ $STARTSTOP == "start-foreground" ]]; then + echo "Starting $DAEMON as a foreground process on host $HOSTNAME." + $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_TM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" ${CLASS_TO_RUN} "${ARGS[@]}" > "$out" 2>&1 < /dev/null + fi + if [[ $STARTSTOP == "start" ]]; then echo "Starting $DAEMON daemon on host $HOSTNAME." - $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_TM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" ${CLASS_TO_RUN} "${ARGS[@]}" > "$out" 2>&1 < /dev/null & + nohup $JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_TM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" ${CLASS_TO_RUN} "${ARGS[@]}" > "$out" 2>&1 < /dev/null & --- End diff -- I added this because I was trying to grasp what makes a daemon a daemon and I found a reference that convinced me that nohup was missing: https://stackoverflow.com/questions/3430330/best-way-to-make-a-shell-script-daemon Additionally when I looked for inspiration for my changes (the start-foreground name), I look at how they started the daemon in zookeeper and I noticed they use nohup too. https://github.com/apache/zookeeper/blob/trunk/bin/zkServer.sh#L219 This is an extra thing and not the core of the Pull Request, if you don't agree I can rebase and remove that commit, but I think it is worth the addition.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---