Created
July 18, 2012 02:52
-
-
Save hqman/3133800 to your computer and use it in GitHub Desktop.
gunicorn_paster starter for pyramid webapp
This file contains hidden or 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 | |
### BEGIN INIT INFO | |
#启动 停止 webapp author wangkai [email protected] | |
# Short-Description: Start gunicorn_paster. | |
# Description: Start gunicorn_paster. | |
### END INIT INFO | |
PIDFILE=WEBAPP.PID | |
ENVINI=development.ini | |
start_app() { | |
#start server | |
echo 'start app' | |
source ../bin/activate | |
../bin/gunicorn_paster -D --log-file=./run.log $ENVINI -p $PIDFILE | |
} | |
stop_app(){ | |
if [ -e $PIDFILE ]; then | |
echo 'stop app' | |
pid=$(cat $PIDFILE) | |
if [ $pid > 0 ]; then | |
#stop server | |
echo 'kill app pid' $pid | |
#rm $PIDFILE | |
#kill -9 $pid | |
kill $pid | |
fi | |
fi | |
} | |
case "$1" in | |
start) | |
start_app | |
;; | |
stop) | |
stop_app | |
;; | |
restart) | |
stop_app | |
sleep 2 | |
start_app | |
;; | |
*) | |
echo ' * Usage: appctl.sh {start|stop|restart}' | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment