Created
January 18, 2014 11:42
-
-
Save vivisidea/8489304 to your computer and use it in GitHub Desktop.
smiple script to manage goagent proxy v1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# smiple script to manage goagent proxy | |
# | |
root=~/scripts | |
localroot=$root/goagent/local | |
log=$root/goagent.log | |
is_running(){ | |
pid=`ps -ef | awk '/python proxy.py$/ {print $2}'` | |
if [ "X${pid}" != "X" ]; then | |
return 0 # running | |
else | |
return 1 # not running | |
fi | |
} | |
start(){ | |
if is_running ; then | |
echo "goagent is already running..." | |
exit 1 | |
fi | |
(cd $localroot && python proxy.py >> $log 2>&1 &) | |
echo "started." | |
} | |
stop(){ | |
if ! is_running; then | |
echo "goagent is not running" | |
else | |
kill $pid > /dev/null 2>&1 & | |
echo "stopped." | |
fi | |
} | |
status(){ | |
if is_running ; then | |
echo "goagent is running ..." | |
else | |
echo "goagent is not running ..." | |
fi | |
} | |
case $1 in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
stop | |
sleep 1 | |
start | |
;; | |
*) | |
echo "usage: `basename $0` start|stop|status|restart" | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment