added check to start httpd server when REPLICATION_ON_START=True, adding "Use Event" line to 001-events.conf

This commit is contained in:
Axel Uhl
2014-11-14 23:22:49 +01:00
parent f8c0370271
commit c7ffdcb2d2
+38
View File
@@ -19,6 +19,30 @@ start_tmux() {
}
start_servers() {
launch_httpd=false
VARS=`/opt/amazon/bin/ec2-metadata -d | sed "s/user-data\: //g" | grep -v "^not available$"`
for var in $VARS; do
echo "$var" | grep -q "^SERVER_NAME="
if [ "$?" != "0" ]; then
eval "export $var"
fi
echo "$var" | grep -q "^SERVER_PORT="
if [ "$?" != "0" ]; then
eval "export $var"
fi
echo "$var" | grep -q "^EVENT_ID="
if [ "$?" != "0" ]; then
eval "export $var"
fi
echo "$var" | grep -iq "^REPLICATE_ON_START=True"
if [ "$?" != "0" ]; then
launch_httpd=true
fi
done
if [ "$launch_httpd" = "true" ]; then
launch_httpd $SERVER_NAME $SERVER_PORT $EVENT_ID
fi
for conf in $JAVA_START_INSTANCES; do
echo "Checking for amazon update..."
su - sailing -c "cd /home/sailing/servers/$conf && $GIT_REPOSITORY/java/target/refreshInstance.sh auto-install" 2>/var/log/sailing.err >/var/log/sailing.out
@@ -36,7 +60,21 @@ stop_servers() {
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
done
}
# launch_httpd(server_name, port, event_id)
launch_httpd() {
echo "launch_httpd($1, $2, $2)"
if [ -x /etc/init.d/httpd ]; then
server_name="`echo $1 | tr [A-Z] [a-z]`"
port="$2"
event_id="$3"
echo "Use Event $server_name.sapsailing.com \"$event_id\" 127.0.0.1 $port" >>/etc/httpd/conf.d/001-events.conf
echo "Launching httpd to map ${server_name}.sapsailing.com to event with ID $event_id with server running on local port $port..."
service httpd start
else
echo Can't launch httpd; start script doesn't seem to be installed at /etc/init.d/httpd
fi
}
# See how we were called.