fmartingr
/
shelfzilla
Archived
1
0
Fork 0
This repository has been archived on 2021-06-29. You can view files and clone it, but cannot push or open issues or pull requests.
shelfzilla/rpm/scripts/shelfzilla

95 lines
2.0 KiB
Plaintext
Raw Normal View History

2014-04-28 12:21:15 +00:00
#!/bin/sh
#
# Shefzilla Init script Adapted
2014-05-27 21:54:39 +00:00
## Nginx
## FactCGI
2014-04-28 12:21:15 +00:00
#
# chkconfig: - 85 15
2014-05-27 21:54:39 +00:00
#
2014-04-28 12:21:15 +00:00
# Source function library.
. /etc/rc.d/init.d/functions
function check ()
{
error=`echo -e "[\e[0;31mError\e[0m]"`
ok=`echo -e "[\e[0;32mOk\e[0m]"`
if [ $1 != 0 ];then
echo $2": "$error
else
echo $2": "$ok
2014-05-27 21:54:39 +00:00
fi
2014-04-28 12:21:15 +00:00
}
function validations() {
## Variables
INSTANCE=shelfzilla
BASE_PATH="/opt/shelfzilla"
PID_PATH=/var/run/shelfzilla
PID_FILE=${PID_PATH}/${INSTANCE}.pid
P_USER="shelfzilla"
LOG_PATH=/var/log/shefzilla
LOG_FILE=shelfzilla.log
FCGI_PORT=8080
FCGI_IP=127.0.0.1
2014-05-27 21:54:39 +00:00
MOD=shelfzilla.settings.configfile
SZ_CONFIG_FILE=/opt/shelfzilla.toml
2014-04-28 12:21:15 +00:00
## Folders
[ -d "${PID_PATH}" ] || mkdir -p "${PID_PATH}"
[ -d "${LOG_PATH}" ] || mkdir -p "${LOG_PATH}"
chown -R "${P_USER}:${P_USER}" $LOG_PATH
}
function status(){
if [ "$1" == "start" ];then
[ -z "`pidof nginx`" ] && service nginx start
2014-05-27 22:43:41 +00:00
[ -z "`pidof python2.7`" ] && gunicorn_django -b ${FCGI_IP}:${FCGI_PORT} -e DJANGO_SETTINGS_MODULE=${MOD} -e APP_CONFIGFILE=${SZ_CONFIG_FILE} --pythonpath=${BASE_PATH} shelfzilla.wsgi:application
2014-05-27 21:54:39 +00:00
check $? "Gunicorn"
2014-04-28 12:21:15 +00:00
elif [ "$1" == "stop" ];then
[ -z "`pidof nginx`" ] || service nginx stop
[ -z "`pidof python2.7`" ] || pkill python2.7
2014-05-27 21:54:39 +00:00
check $? "Gunicorn"
2014-04-28 12:21:15 +00:00
else
service nginx status
FCGI=`pidof python2.7`
if [ -z "${FCGI}" ];then
2014-05-27 21:54:39 +00:00
echo -n "Gunicorn Server is down"
2014-04-28 12:21:15 +00:00
echo ""
else
2014-05-27 21:54:39 +00:00
echo -n "Gunicorn Server is up (${FCGI})"
2014-04-28 12:21:15 +00:00
echo ""
fi
fi
}
function restart() {
status "stop"
status "start"
}
validations
case "$1" in
start)
2014-05-27 21:54:39 +00:00
status "start"
2014-04-28 12:21:15 +00:00
;;
stop)
status "stop"
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
2014-05-27 21:54:39 +00:00
esac