From f60d49527bedfc1ecda401f49fae9c9a5bbcf5f9 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 30 Jan 2018 11:09:51 +0000 Subject: gunicorn dev and prod modes added --- bin/genenetwork2 | 45 +++++++++++++++++++++++++++++++++++++-------- wqflask/wqflask/views.py | 2 +- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/bin/genenetwork2 b/bin/genenetwork2 index 6878643d..cbaba76f 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -27,9 +27,18 @@ # # env GN2_PROFILE=~/opt/gn-latest-guix WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG ./bin/genenetwork2 # -# For production we use gunicorn. Run with something like +# For staging and production we use gunicorn. Run with something like +# (note you have to provide the server port). Provide a settings file! # -# env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ./etc/default_settings.py -gunicorn "--bind 0.0.0.0:8000 --workers=1 wsgi" +# env GN2_PROFILE=~/opt/gn-latest-guix SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-prod +# +# For development use +# +# env GN2_PROFILE=~/opt/gn-latest-guix SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-dev +# +# For extra flexibility you can also provide gunicorn parameters yourself with something like +# +# env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ./etc/default_settings.py -gunicorn "--bind 0.0.0.0:5003 --workers=1 wsgi" SCRIPT=$(realpath "$0") GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT")) @@ -55,11 +64,13 @@ if [ "$1" = "-c" -o "$1" = "-gunicorn" ]; then exit 1 fi # Handle settings parameter (can be .py or .json) -settings=$(realpath "$1") -if [ ! -e $settings ]; then - settings=$GN2_BASE_DIR/etc/default_settings.py -else - shift +if [ ! -z $1 ]; then + settings=$(realpath "$1") + if [ ! -e $settings ]; then + settings=$GN2_BASE_DIR/etc/default_settings.py + else + shift + fi fi ext="${settings##*.}" @@ -139,7 +150,7 @@ if [ "$1" = '-c' ] ; then echo PYTHONPATH=$PYTHONPATH echo RUNNING COMMAND $cmd python $cmd - exit 0 + exit $? fi if [ "$1" = '-gunicorn' ] ; then cd $GN2_BASE_DIR/wqflask @@ -149,6 +160,24 @@ if [ "$1" = '-gunicorn' ] ; then gunicorn $cmd exit $? fi +if [ "$1" = '-gunicorn-dev' ] ; then + cd $GN2_BASE_DIR/wqflask + echo PYTHONPATH=$PYTHONPATH + if [ -z $SERVER_PORT ]; then echo "ERROR: Provide a SERVER_PORT" ; exit 1 ; fi + cmd="--bind 0.0.0.0:$SERVER_PORT --workers=1 --reload wsgi" + echo RUNNING gunicorn $cmd + gunicorn $cmd + exit $? +fi +if [ "$1" = '-gunicorn-prod' ] ; then + cd $GN2_BASE_DIR/wqflask + echo PYTHONPATH=$PYTHONPATH + if [ -z $SERVER_PORT ]; then echo "ERROR: Provide a SERVER_PORT" ; exit 1 ; fi + cmd="--bind 0.0.0.0:$SERVER_PORT --workers=32 --max-requests 1000 --timeout 1200 wsgi" + echo RUNNING gunicorn $cmd + gunicorn $cmd + exit $? +fi echo "Starting the redis server:" echo -n "dir $TMPDIR diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index d8f5616d..4e81c29c 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -766,7 +766,7 @@ def corr_scatter_plot_page(): def submit_bnw(): logger.error(request.url) template_vars = get_bnw_input(request.form) - return render_template("empty_collection.html", **{'tool':'Correlation Matrix'}) + return render_template("empty_collection.html", **{'tool':'Correlation Matrix'}) # Todo: Can we simplify this? -Sam def sharing_info_page(): -- cgit v1.2.3