#!/bin/sh # run-apache ## dgg mods of apachectl for start/stop flybase apache web server ## add start/stop of $HOME/etc/tomcat server (bin/tomcat.sh) ## jan04 - create specially tuned flybaseng-apache80.conf and flybaseng-apache8081.conf ## run two servers: port80 only for flybaseng, no other port listens (a high load delay) ## second server to handle ports 8081 (argos general), 81 (old fb), 7081 (old fb) 7084 (ng) ## and redirect all but 8081 to port80 server # |||||||||||||||||||| START CONFIGURATION SECTION |||||||||||||||||||| # -------------------- -------------------- ROOT=/bio/biodb APACHE_HOME="$ROOT/common/servers/apache"; export APACHE_HOME APACHE_PORT=8081 TOMCAT_RUN="$ROOT/install/run-tomcat" #? PERL5LIB="$ROOT/common/perl/lib" ; export PERL5LIB # the path to your PID file APACHE_PID="$ROOT/logs/httpd.pid" APACHE_CONF="$ROOT/ROOT/conf/apache.conf" # the path to your httpd binary, including options if necessary APACHE_HTTPD="$ROOT/common/servers/apache/bin/httpd -d $APACHE_HOME -f $APACHE_CONF" ## optionally reset above settings from .conf runconf=install.conf PRG="$0" # resolve symlinks -h while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` ## override (possibly) above settings if [ -r "$PRGDIR"/$runconf ]; then . "$PRGDIR"/$runconf fi if [ -r "$PRGDIR"/${runconf}.local ]; then . "$PRGDIR"/${runconf}.local fi # a command that outputs a formatted text version of the HTML at the # url given on the command line. Designed for lynx, however other # programs may work. # if [ -x "lynx" ]; then LYNX="lynx -dump" # elif [ -x "curl" ]; then # LYNX="curl" # fi # # the URL to your server's mod_status status page. If you do not # have one, then status and fullstatus will not work. STATUSURL="http://localhost:$APACHE_PORT/server-status" # # -------------------- -------------------- # |||||||||||||||||||| END CONFIGURATION SECTION |||||||||||||||||||| ERROR=0 ARGV="$@" if [ "x$ARGV" = "x" ] ; then ARGS="help" fi for ARG in $@ $ARGS do # check for pidfile if [ -f $APACHE_PID ] ; then PID=`cat $APACHE_PID` if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then STATUS="httpd (pid $PID) running" RUNNING=1 else STATUS="httpd (pid $PID?) not running" RUNNING=0 fi else STATUS="httpd (no pid file) not running" RUNNING=0 fi case $ARG in notom*) TOMCAT_RUN="echo NO tomcat "; notomcat=1 ;; start) if [ $RUNNING -eq 1 ]; then echo "$0 $ARG: httpd (pid $PID) already running" continue fi if $APACHE_HTTPD ; then echo "$0 $ARG: httpd started" else echo "$0 $ARG: httpd could not be started" ERROR=3 fi ## dgg; add tomcat start $TOMCAT_RUN graceful ;; stop) if [ $RUNNING -eq 0 ]; then echo "$0 $ARG: $STATUS" continue fi if kill $PID ; then echo "$0 $ARG: httpd stopped" else echo "$0 $ARG: httpd could not be stopped" ERROR=4 fi ## dgg; add tomcat stop $TOMCAT_RUN stop ;; restart) if [ $RUNNING -eq 0 ]; then echo "$0 $ARG: httpd not running, trying to start" if $APACHE_HTTPD ; then echo "$0 $ARG: httpd started" else echo "$0 $ARG: httpd could not be started" ERROR=5 fi else if $APACHE_HTTPD -t >/dev/null 2>&1; then if kill -HUP $PID ; then echo "$0 $ARG: httpd restarted" else echo "$0 $ARG: httpd could not be restarted" ERROR=6 fi else echo "$0 $ARG: configuration broken, ignoring restart" echo "$0 $ARG: (run 'apachectl configtest' for details)" ERROR=6 fi fi ## dgg; add tomcat restart $TOMCAT_RUN restart ;; graceful) if [ $RUNNING -eq 0 ]; then echo "$0 $ARG: httpd not running, trying to start" if $APACHE_HTTPD ; then echo "$0 $ARG: httpd started" else echo "$0 $ARG: httpd could not be started" ERROR=5 fi else if $APACHE_HTTPD -t >/dev/null 2>&1; then if kill -USR1 $PID ; then echo "$0 $ARG: httpd gracefully restarted" else echo "$0 $ARG: httpd could not be restarted" ERROR=7 fi else echo "$0 $ARG: configuration broken, ignoring restart" echo "$0 $ARG: (run 'apachectl configtest' for details)" ERROR=7 fi fi ## dgg; add tomcat graceful $TOMCAT_RUN graceful ;; status) $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } ' ;; fullstatus) $LYNX $STATUSURL ;; configtest) if $APACHE_HTTPD -t; then : else ERROR=8 fi ;; *) echo "usage: $0 [notomcat] (start|stop|restart|fullstatus|status|graceful|configtest|help)" cat <