diff options
author | Punya Biswal <pbiswal@palantir.com> | 2015-04-17 11:08:37 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2015-04-17 11:08:37 +0100 |
commit | f6a9a57a72767f48fcc02e5fda4d6eafa67aebde (patch) | |
tree | 52307c8a74d7bfeeb4b2afa24446da4ce1df3771 /sbin/spark-daemon.sh | |
parent | 4527761bcd6501c362baf2780905a0018b9a74ba (diff) | |
download | spark-f6a9a57a72767f48fcc02e5fda4d6eafa67aebde.tar.gz spark-f6a9a57a72767f48fcc02e5fda4d6eafa67aebde.tar.bz2 spark-f6a9a57a72767f48fcc02e5fda4d6eafa67aebde.zip |
[SPARK-6952] Handle long args when detecting PID reuse
sbin/spark-daemon.sh used
ps -p "$TARGET_PID" -o args=
to figure out whether the process running with the expected PID is actually a Spark
daemon. When running with a large classpath, the output of ps gets
truncated and the check fails spuriously.
This weakens the check to see if it's a java command (which is something
we do in other parts of the script) rather than looking for the specific
main class name. This means that SPARK-4832 might happen under a
slightly broader range of circumstances (a java program happened to
reuse the same PID), but it seems worthwhile compared to failing
consistently with a large classpath.
Author: Punya Biswal <pbiswal@palantir.com>
Closes #5535 from punya/feature/SPARK-6952 and squashes the following commits:
7ea12d1 [Punya Biswal] Handle long args when detecting PID reuse
Diffstat (limited to 'sbin/spark-daemon.sh')
-rwxr-xr-x | sbin/spark-daemon.sh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/spark-daemon.sh b/sbin/spark-daemon.sh index d8e0facb81..de762acc8f 100755 --- a/sbin/spark-daemon.sh +++ b/sbin/spark-daemon.sh @@ -129,7 +129,7 @@ run_command() { if [ -f "$pid" ]; then TARGET_ID="$(cat "$pid")" - if [[ $(ps -p "$TARGET_ID" -o args=) =~ $command ]]; then + if [[ $(ps -p "$TARGET_ID" -o comm=) =~ "java" ]]; then echo "$command running as process $TARGET_ID. Stop it first." exit 1 fi @@ -163,7 +163,7 @@ run_command() { echo "$newpid" > "$pid" 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 args=) =~ $command ]]; then + if [[ ! $(ps -p "$newpid" -o comm=) =~ "java" ]]; then echo "failed to launch $command:" tail -2 "$log" | sed 's/^/ /' echo "full log in $log" |