#!/bin/sh #--------------------------------------------------------------- # Project : MILLE-XTERM # Module : initscripts # File : lbagent # Version : $Id: lbagent,v 0.0.1 2006/03/13 10:10:10 flepied Exp $ # Author : Ivan Arsenault # Created On : Mon Mar 13 10:10:10 2006 #--------------------------------------------------------------- # chkconfig: 35 96 36 # description: Load balancer monitoring agent for MILLE-XTERM #--------------------------------------------------------------- # Source function library. . /etc/rc.d/init.d/functions PY="/usr/bin/python" MAIN="main.py" PROGNAME="mille-xterm-lbagent" BASEDIR="/usr/share/mille-xterm/lbagent" LOGFILE="/var/log/${PROGNAME}.log" CONF="/etc/mille-xterm/lbaconfig.xml" PID="/var/run/${PROGNAME}.pid" if [ ! -e $LOGFILE ]; then touch $LOGFILE fi ret=1 case $1 in start) pid_in_memory=`ps auwwwwx | grep "lbagent/main.py" | grep -v grep | awk '{print $2}'` if [ -z "$pid_in_memory" ]; then gprintf "Starting mille-xterm load balancer agent: \n" $PY $BASEDIR/$MAIN --daemon --logfile=$LOGFILE $CONF sleep 2 pid_in_memory=`ps auwwwwx | grep "lbagent/main.py" | grep -v grep | awk '{print $2}'` if [ -z "$pid_in_memory" ]; then echo gprintf "Mille-xterm load balancer agent did not start.\n" echo_failure echo else echo $pid_in_memory > $PID echo_success echo fi else echo gprintf "Mille-xterm load balancer agent is already running \n" echo_failure echo fi ;; stop) gprintf "Stopping mille-xterm load balancer agent: " if [ -r $PID ]; then kill `cat $PID` > /dev/null 2>&1 ret=$? fi if [ $ret = 0 ]; then success "mille-xterm load balancer agent shutdown" rm -f $PID else failure "mille-xterm load balancer agent shutdown" fi echo ;; status) status "$PY $BASEDIR/$MAIN $CONF" ;; reload) ;; restart) $0 stop $0 start ret=$? ;; *) gprintf "Usage: %s\n" "$(basename $0) {start|stop|restart|status}" exit 0 ;; esac exit $ret