#!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

CMD_PATH=/usr/local/bin/python
MAP_PID='/var/log/map.pid'
MAP_LOG='/var/log/map.log'


check_status()
{
	PID=`cat $MAP_PID`
	if [ "$PID" = "" ]; then
 		return 0	
	fi
	return $PID
}

case $1 in

	start)
		check_status
		PID=$?	
		[ "$PID" -ne 0 ] && echo "!!no:server is uping" && exit
		${CMD_PATH} /usr/local/www/map.py 1>$MAP_LOG 2>&1 &
		echo $! > $MAP_PID && echo "ok:server is up"
		;;

	stop)

		check_status
		PID=$?
		[ "$PID" -eq 0 ] && echo "!!no:server don't up" && exit
		[ "$PID" -ne 0 ] && kill $PID && `: > $MAP_PID` && echo "yes:server is down"
		;;

	restart)
		$0 stop
		$0 start
		;;

	*)
		cat << HELP
$0 {start|stop|restart}
HELP
		;;

esac


Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐