1. yang xiaoyong
  2. woocode

Source

woocode / sa-auto / sh / msj / msj_server.sh

#!/bin/sh
#ulimit -c unlimited;
#sleep 3;
MSJ_BIN=/apps/msj/bin
USER=apps

start(){
	cd ${MSJ_BIN}
	nohup ./watchdog ./domainsvr > domainsvr.log 2>&1 &
	su ${USER} -c "nohup ./watchdog ./worldsvr-ev 1 >/dev/null 2>&1 &"
	su ${USER} -c "nohup ./watchdog ./worldsvr-ev 2 > /dev/null  2>&1 &"
	
	sleep 10;
	
	su ${USER} -c "nohup ./watchdog ./gatesvr  > /dev/null 2>&1 &"
	su ${USER} -c "nohup ./watchdog ./gm  > /dev/null 2>&1 &"
	cd -

}
stop(){
	killall -q -9 watchdog
	killall -q -9 worldsvr-ev
	pkill 	domainsvr
	pkill	gatesvr
	pkill 	gm

}

if test $# -ne 1 ;then
	echo "Usage:$0 {start|stop|restart}"
	exit 1	
fi

CUR_USER=`whoami`

if test "${CUR_USER}" != "root" ;then
	echo  "\033[31mNOTE: Need to be root! \033[0m"
	exit 1
fi

case "$1" in 
	start)
		echo -n "Starting server..."
		start
		echo 	"OK!"
		;;
	stop)
		echo -n "Stopping server..."
		stop
		echo 	"OK!"
		;;
	restart)
		stop
		start
		;;
	*)
		echo "Usage:$0 {start|stop|restart}"
		exit 1
		;;	
esac

exit 0