mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 19:50:01 +00:00
82 lines
2.1 KiB
Bash
Executable File
82 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# sailing Starts sailing services
|
|
#
|
|
# chkconfig: 2345 95 10
|
|
# description: Sailing contains all sailing services
|
|
|
|
# Source function library.
|
|
. /etc/init.d/functions
|
|
|
|
RETVAL=0
|
|
|
|
JAVA_START_INSTANCES="server"
|
|
GIT_REPOSITORY=/home/sailing/code
|
|
|
|
start_tmux() {
|
|
su - sailing -c "/home/sailing/bin/tmuxConsole.sh unattended"
|
|
success
|
|
}
|
|
|
|
start_servers() {
|
|
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
|
|
# execute env.sh which now has the same set of variables that the server will see
|
|
source /home/sailing/servers/$conf/env.sh
|
|
launch_httpd
|
|
echo "Starting Java server $conf"
|
|
su - sailing -c "cd /home/sailing/servers/$conf && ./start" 2>/var/log/sailing.err >/var/log/sailing.out
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && success || failure
|
|
done
|
|
}
|
|
|
|
stop_servers() {
|
|
for conf in $JAVA_START_INSTANCES; do
|
|
echo "Stopping Java server $conf"
|
|
su - sailing -c "cd /home/sailing/servers/$conf && ./stop"
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && success || failure
|
|
done
|
|
}
|
|
|
|
# launch_httpd(server_name, port, event_id)
|
|
launch_httpd() {
|
|
if [ "$REPLICATE_ON_START" != "" ]; then
|
|
echo "REPLICATE_ON_START is $REPLICATE_ON_START. Will try to launch httpd so this replica can work with an ELB easily."
|
|
if [ -x /etc/init.d/httpd ]; then
|
|
server_name="`echo $SERVER_NAME | tr [A-Z] [a-z]`"
|
|
echo "Use Event $server_name.sapsailing.com \"$EVENT_ID\" 127.0.0.1 $SERVER_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 $SERVER_PORT..."
|
|
service httpd start
|
|
else
|
|
echo Can't launch httpd; start script doesn't seem to be installed at /etc/init.d/httpd
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# See how we were called.
|
|
case "$1" in
|
|
start)
|
|
start_servers
|
|
;;
|
|
stop)
|
|
stop_servers
|
|
;;
|
|
status)
|
|
status java
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|status|stop}"
|
|
RETVAL=3
|
|
esac
|
|
|
|
exit $RETVAL
|
|
|