Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions sbin/spark-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ if [ "$SPARK_NICENESS" = "" ]; then
fi

execute_command() {
local command="$@"
if [ -z ${SPARK_NO_DAEMONIZE+set} ]; then
nohup -- $command >> $log 2>&1 < /dev/null &
nohup -- "$@" >> $log 2>&1 < /dev/null &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK by me, but why remove the local?

Copy link
Member Author

@wangyum wangyum Nov 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will lost single quotes around if use local. You can verify as follows:

#!/usr/bin/env bash

set -x

execute_command() {
  echo "with local:"
  local command="$@"
  echo "no local:"
  "$@"
}

run_command() {
  execute_command ../bin/spark-submit "$@"
}

run_command "$@"

Save above code as SPARK-18645.sh and run sh SPARK-18645.sh --conf 'spark.driver.extraJavaOptions=-XX:+UseG1GC -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'
you will see like this:

+ run_command --conf 'spark.driver.extraJavaOptions=-XX:+UseG1GC -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'
+ execute_command ../bin/spark-submit --conf 'spark.driver.extraJavaOptions=-XX:+UseG1GC -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'
+ echo 'with local:'
with local:
+ local 'command=../bin/spark-submit --conf spark.driver.extraJavaOptions=-XX:+UseG1GC -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'
+ echo 'no local:'
no local:
+ ../bin/spark-submit --conf 'spark.driver.extraJavaOptions=-XX:+UseG1GC -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, OK.

newpid="$!"

echo "$newpid" > "$pid"
Expand All @@ -143,12 +142,12 @@ execute_command() {
sleep 2
# Check if the process has died; in that case we'll tail the log so the user can see
if [[ ! $(ps -p "$newpid" -o comm=) =~ "java" ]]; then
echo "failed to launch $command:"
echo "failed to launch: $@"
tail -2 "$log" | sed 's/^/ /'
echo "full log in $log"
fi
else
$command
"$@"
fi
}

Expand Down Expand Up @@ -176,11 +175,11 @@ run_command() {

case "$mode" in
(class)
execute_command nice -n "$SPARK_NICENESS" "${SPARK_HOME}"/bin/spark-class $command $@
execute_command nice -n "$SPARK_NICENESS" "${SPARK_HOME}"/bin/spark-class "$command" "$@"
;;

(submit)
execute_command nice -n "$SPARK_NICENESS" bash "${SPARK_HOME}"/bin/spark-submit --class $command $@
execute_command nice -n "$SPARK_NICENESS" bash "${SPARK_HOME}"/bin/spark-submit --class "$command" "$@"
;;

(*)
Expand Down