XiZi's Blog
goagent linux service script
#!/bin/bash # # file /etc/init.d/goagentd # goagentd Start up the goagentd server daemon # # chkconfig: 2345 55 25 # description: goagentd # # processname: proxy.py # pidfile: /var/run/goagentd.pid ### BEGIN INIT INFO # Provides: goagentd # Required-Start: $local_fs $network $syslog # Required-Stop: $local_fs $syslog # Should-Start: $syslog # Should-Stop: $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: GoAgent # Description: GoAgent GAE Proxy Server. ### END INIT INFO # source function library . /etc/rc.d/init.d/functions prog="goagent" PYTHON=python proxy=/opt/goagent/local/proxy.py log=/opt/goagent/local/log runlevel=$(set -- $(runlevel); eval "echo \$$#" ) start() { echo -n $"Starting $prog: " [ -f "$log" ] && mv -f "$log" "$log.old" $PYTHON $proxy 1>&$log 2>&1 & touch /var/lock/subsys/goagent } stop() { echo -n $"Stopping $prog: " kill $(ps aux | grep "[p]ython $proxy" | awk '{print $2}') rm -f /var/lock/subsys/goagent } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|restart}" esac exit 0