#!/bin/bash # Author: Milen Kouylekov # chkconfig: 35 92 15 # description: start/stop the Galaxy server and validate its dependencies . /etc/init.d/functions GALAXY_USER=laportal start () { ## make sure the Galaxy tree is where we expect it if [ ! -d /home/${GALAXY_USER}/galaxy ] then echo "Error: \`/home/${GALAXY_USER}/galaxy' missing; exit." return 1 fi ## Check if memcached is running if pgrep "memcached" > /dev/null then : else echo "Error: MEMCACHED is not running; exit." return 1 fi ## Check if HTTPD is running http_running="$(service httpd status)" if [[ $http_running != *"running"* ]]; then echo "Error: HTTPD is not running; exit." return 1 fi ## Check if MUNGE is running if pgrep "munge" > /dev/null then : else echo "Error: MUNGE is not running; exit." return 1 fi ## Check if GOLD is running if pgrep "goldd" > /dev/null then : else echo "Error: GOLD is not running; exit." return 1 fi ## Check if MongoDB is running if pgrep "mongod" > /dev/null then : else echo "Error: MongoDB is not running; exit." return 1 fi response=`wget http://localhost:8080/ -O /dev/null -S --quiet 2>&1` if [[ $response == *"200"* ]] then echo "Warning: GALAXY is currently running; trying shutdown." /home/${GALAXY_USER}/galaxy/run.sh --stop-daemon sleep 30 response=`wget http://localhost:8080/ -O /dev/null -S --quiet 2>&1` if [[ $response == *"PasteWSGIServer"* ]] then echo "Error: Unable to stop GALAXY; exit." return 1 fi fi daemon --user=${GALAXY_USER} /home/${GALAXY_USER}/galaxy/run.sh --daemon echo "" i=0 sleep 10 while [ ${i} -lt 4 ] do response=`wget http://localhost:8080/ -O /dev/null -S --quiet 2>&1` if [[ $response == *"PasteWSGIServer"* ]] then echo "Success: GALAXY is talking to us." return 0 else sleep 5 i=$[${i} + 1] fi done echo "Error: GALAXY is not responding after 30 seconds; check the log files." return 1 } stop () { /home/${GALAXY_USER}/galaxy/run.sh --stop-daemon } restart () { stop start } case "$1" in start) start; RETVAL=$? ;; stop) stop; RETVAL=$? ;; restart) restart; RETVAL=$? ;; esac exit $RETVAL