Skip to content

Instantly share code, notes, and snippets.

@vivisidea
Created January 18, 2014 11:42
Show Gist options
  • Save vivisidea/8489304 to your computer and use it in GitHub Desktop.
Save vivisidea/8489304 to your computer and use it in GitHub Desktop.
smiple script to manage goagent proxy v1.1
#!/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