Created
November 15, 2013 07:45
-
-
Save abn/7480636 to your computer and use it in GitHub Desktop.
uwsgi control script for OpenShift
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 -e | |
# This assumes that your openshift repo contains a uwsgi.ini | |
# configuration file. | |
# This is a extracted from a script used live for the victims project: | |
# https://github.com/victims/victims-server-openshift/blob/master/bin/control | |
source $OPENSHIFT_CARTRIDGE_SDK_BASH | |
# Setup globals | |
LOG_PREFIX="[python-uwsgi-control]" | |
# activate virtenv | |
echo "$LOG_PREFIX Activating virtenv ..." | |
source ${OPENSHIFT_PYTHON_DIR}/virtenv/bin/activate | |
UWSGI_PIDFILE=${OPENSHIFT_PYTHON_DIR}/run/uwsgi.pid | |
CONFIGFILE=${OPENSHIFT_REPO_DIR}/uwsgi.ini | |
function stop() | |
{ | |
if [ -f "$UWSGI_PIDFILE" ]; then | |
echo "$LOG_PREFIX Stopping uWSGI" | |
uwsgi --stop "$UWSGI_PIDFILE" | |
rm "$UWSGI_PIDFILE" | |
else | |
echo "$LOG_PREFIX No running UWSGI process" | |
fi | |
} | |
function start() | |
{ | |
if [ -f "$UWSGI_PIDFILE" ]; then | |
echo "$LOG_PREFIX uWSGI already running" | |
else | |
echo "$LOG_PREFIX Starting UWSGI" | |
uwsgi "${CONFIGFILE}" | |
fi | |
} | |
function restart() | |
{ | |
echo "$LOG_PREFIX Restarting uWSGI" | |
stop | |
# wait till all workers are burried | |
sleep 2 | |
start | |
} | |
case $1 in | |
start) start ;; | |
stop) stop ;; | |
restart) restart ;; | |
reload) restart ;; | |
*) exec $OPENSHIFT_PYTHON_DIR/bin/control "$@" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment