Adapted init script to gunicorn
This commit is contained in:
parent
fd448e3586
commit
21ff7987db
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Shefzilla Init script Adapted
|
# Shefzilla Init script Adapted
|
||||||
## Nginx
|
## Nginx
|
||||||
## FactCGI
|
## FactCGI
|
||||||
#
|
#
|
||||||
# chkconfig: - 85 15
|
# chkconfig: - 85 15
|
||||||
#
|
#
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
@ -19,7 +19,7 @@ function check ()
|
||||||
echo $2": "$error
|
echo $2": "$error
|
||||||
else
|
else
|
||||||
echo $2": "$ok
|
echo $2": "$ok
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function validations() {
|
function validations() {
|
||||||
|
@ -33,6 +33,8 @@ function validations() {
|
||||||
LOG_FILE=shelfzilla.log
|
LOG_FILE=shelfzilla.log
|
||||||
FCGI_PORT=8080
|
FCGI_PORT=8080
|
||||||
FCGI_IP=127.0.0.1
|
FCGI_IP=127.0.0.1
|
||||||
|
MOD=shelfzilla.settings.configfile
|
||||||
|
SZ_CONFIG_FILE=/opt/shelfzilla.toml
|
||||||
|
|
||||||
## Folders
|
## Folders
|
||||||
[ -d "${PID_PATH}" ] || mkdir -p "${PID_PATH}"
|
[ -d "${PID_PATH}" ] || mkdir -p "${PID_PATH}"
|
||||||
|
@ -46,22 +48,22 @@ function status(){
|
||||||
if [ "$1" == "start" ];then
|
if [ "$1" == "start" ];then
|
||||||
[ -z "`pidof nginx`" ] && service nginx start
|
[ -z "`pidof nginx`" ] && service nginx start
|
||||||
#[ -z "`pidof python2.7`" ] && runuser -l shelfzilla -c "python2.7 ${BASE_PATH}/manage.py runfcgi host=${FCGI_IP} port=${FCGI_PORT}"
|
#[ -z "`pidof python2.7`" ] && runuser -l shelfzilla -c "python2.7 ${BASE_PATH}/manage.py runfcgi host=${FCGI_IP} port=${FCGI_PORT}"
|
||||||
[ -z "`pidof python2.7`" ] && python2.7 ${BASE_PATH}/manage.py runfcgi host=${FCGI_IP} port=${FCGI_PORT}
|
[ -z "`pidof python2.7`" ] && python2.7 ${BASE_PATH}/manage.py run_gunicorn -b ${FCGI_IP}:${FCGI_PORT} -e DJANGO_SETTINGS_MODULE=${MOD} -e APP_CONFIGFILE=${SZ_CONFIG_FILE}
|
||||||
check $? "FCGI"
|
check $? "Gunicorn"
|
||||||
|
|
||||||
elif [ "$1" == "stop" ];then
|
elif [ "$1" == "stop" ];then
|
||||||
[ -z "`pidof nginx`" ] || service nginx stop
|
[ -z "`pidof nginx`" ] || service nginx stop
|
||||||
[ -z "`pidof python2.7`" ] || pkill python2.7
|
[ -z "`pidof python2.7`" ] || pkill python2.7
|
||||||
check $? "FCGI"
|
check $? "Gunicorn"
|
||||||
|
|
||||||
else
|
else
|
||||||
service nginx status
|
service nginx status
|
||||||
FCGI=`pidof python2.7`
|
FCGI=`pidof python2.7`
|
||||||
if [ -z "${FCGI}" ];then
|
if [ -z "${FCGI}" ];then
|
||||||
echo -n "FCGI Server is down"
|
echo -n "Gunicorn Server is down"
|
||||||
echo ""
|
echo ""
|
||||||
else
|
else
|
||||||
echo -n "FCGI Server is up (${FCGI})"
|
echo -n "Gunicorn Server is up (${FCGI})"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -76,7 +78,7 @@ function restart() {
|
||||||
validations
|
validations
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
status "start"
|
status "start"
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
status "stop"
|
status "stop"
|
||||||
|
@ -90,4 +92,4 @@ case "$1" in
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|restart|status}"
|
echo $"Usage: $0 {start|stop|restart|status}"
|
||||||
exit 2
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
Reference in New Issue