Permalink
Browse files

Detect whether we run on EC2 using ec2-metadata as well

  • Loading branch information...
shivaram committed Jan 27, 2013
1 parent 2435b7b commit 717b221cca79cb8a1603e9dcf7f0bb50e215ac41
Showing with 2 additions and 1 deletion.
  1. +2 −1 bin/start-master.sh
View
@@ -26,7 +26,8 @@ fi
# Set SPARK_PUBLIC_DNS so the master report the correct webUI address to the slaves
if [ "$SPARK_PUBLIC_DNS" = "" ]; then
# If we appear to be running on EC2, use the public address by default:
- if [[ `hostname` == *ec2.internal ]]; then
+ # NOTE: ec2-metadata is installed on Amazon Linux AMI. Check based on that and hostname
+ if command -v ec2-metadata > /dev/null || [[ `hostname` == *ec2.internal ]]; then
export SPARK_PUBLIC_DNS=`wget -q -O - http://instance-data.ec2.internal/latest/meta-data/public-hostname`
fi
fi

0 comments on commit 717b221

Please sign in to comment.