aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/genenetwork272
-rw-r--r--etc/VERSION2
-rw-r--r--etc/default_settings.py2
-rw-r--r--wqflask/__init__.py1
-rw-r--r--wqflask/run_gunicorn.py19
-rw-r--r--wqflask/runserver.py2
-rw-r--r--wqflask/wqflask/views.py2
-rw-r--r--wqflask/wsgi.py4
8 files changed, 93 insertions, 11 deletions
diff --git a/bin/genenetwork2 b/bin/genenetwork2
index a7edb1c2..cbaba76f 100755
--- a/bin/genenetwork2
+++ b/bin/genenetwork2
@@ -22,8 +22,25 @@
# a -c switch, e.g.
#
# env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ~/my_overrides.json -c ./wqflask/maintenance/gen_select_dataset.py
+#
+# For development you may want to run
+#
+# env GN2_PROFILE=~/opt/gn-latest-guix WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG ./bin/genenetwork2
+#
+# 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 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=$(readlink -f "$0")
+SCRIPT=$(realpath "$0")
GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT"))
GN2_ID=$(cat /etc/hostname):$(basename $GN2_BASE_DIR)
@@ -42,15 +59,27 @@ else
fi
echo GN_VERSION=$GN_VERSION
+if [ "$1" = "-c" -o "$1" = "-gunicorn" ]; then
+ echo "Can not use $1 switch without default settings file"
+ exit 1
+fi
# Handle settings parameter (can be .py or .json)
-settings=$1
+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##*.}"
-if [ -z "$settings" -o "$ext" = "json" -o "$ext" = "JSON" ]; then
+if [ "$ext" = "json" -o "$ext" = "JSON" ]; then
overrides=$settings
- settings=$GN2_BASE_DIR/etc/default_settings.py
else
- shift
+ echo $settings
fi
+
if [ ! -e $settings ]; then
echo "ERROR: can not locate settings file - pass it in the command line"
exit 1
@@ -86,6 +115,9 @@ else
export PYLMM_COMMAND="$GN2_PROFILE/bin/pylmm_redis"
export GEMMA_COMMAND="$GN2_PROFILE/bin/gemma"
export GEMMA_WRAPPER_COMMAND="$GN2_PROFILE/bin/gemma-wrapper"
+ if [ ! -d $PYTHONPATH ] ; then echo "PYTHONPATH not valid "$PYTHONPATH ; exit 1 ; fi
+ if [ ! -d $R_LIBS_SITE ] ; then echo "R_LIBS_SITE not valid "$R_LIBS_SITE ; exit 1 ; fi
+ if [ ! -d $GEM_PATH ] ; then echo "GEM_PATH not valid "$GEM_PATH ; exit 1 ; fi
fi
if [ -z $PYTHONPATH ] ; then
echo "ERROR PYTHONPATH has not been set - use GN2_PROFILE!"
@@ -118,7 +150,33 @@ 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
+ cmd=$2
+ echo PYTHONPATH=$PYTHONPATH
+ echo RUNNING gunicorn $cmd
+ 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:"
@@ -127,7 +185,7 @@ dbfilename gn2.rdb
" | redis-server - &
# Overrides for packages that are not yet public (currently r-auwerx)
-export R_LIBS_SITE=$R_LIBS_SITE:$HOME/.Rlibs/das1i1pm54dj6lbdcsw5w0sdwhccyj1a-r-3.3.2/lib/R/lib
+# export R_LIBS_SITE=$R_LIBS_SITE:$HOME/.Rlibs/das1i1pm54dj6lbdcsw5w0sdwhccyj1a-r-3.3.2/lib/R/lib
# Start the flask server running GN2
cd $GN2_BASE_DIR/wqflask
diff --git a/etc/VERSION b/etc/VERSION
index b624c74a..ca9e199c 100644
--- a/etc/VERSION
+++ b/etc/VERSION
@@ -1 +1 @@
-2.10rc5
+2.11-rc1
diff --git a/etc/default_settings.py b/etc/default_settings.py
index 59e22f1a..699d21f1 100644
--- a/etc/default_settings.py
+++ b/etc/default_settings.py
@@ -27,7 +27,7 @@ import sys
GN_VERSION = open("../etc/VERSION","r").read()
SQL_URI = "mysql://gn2:mysql_password@localhost/db_webqtl_s"
SQL_ALCHEMY_POOL_RECYCLE = 3600
-GN_SERVER_URL = "http://localhost:8880/"
+GN_SERVER_URL = "http://localhost:8880/" # REST API server
# ---- Flask configuration (see website)
TRAP_BAD_REQUEST_ERRORS = True
diff --git a/wqflask/__init__.py b/wqflask/__init__.py
index 315b709e..e69de29b 100644
--- a/wqflask/__init__.py
+++ b/wqflask/__init__.py
@@ -1 +0,0 @@
-from wqflask import app
diff --git a/wqflask/run_gunicorn.py b/wqflask/run_gunicorn.py
new file mode 100644
index 00000000..14a2d689
--- /dev/null
+++ b/wqflask/run_gunicorn.py
@@ -0,0 +1,19 @@
+# Run with gunicorn, see ./bin/genenetwork2 for an example
+#
+# Run standalone with
+#
+# ./bin/genenetwork2 ./etc/default_settings.py -c run_gunicorn.py
+
+# from flask import Flask
+# application = Flask(__name__)
+
+print "Starting up Gunicorn process"
+
+from wqflask import app
+
+@app.route("/gunicorn")
+def hello():
+ return "<h1 style='color:blue'>Hello There!</h1>"
+
+if __name__ == "__main__":
+ app.run(host='0.0.0.0')
diff --git a/wqflask/runserver.py b/wqflask/runserver.py
index 50f134db..a0c76e51 100644
--- a/wqflask/runserver.py
+++ b/wqflask/runserver.py
@@ -1,5 +1,7 @@
# Starts the webserver with the ./bin/genenetwork2 command
#
+# This uses Werkzeug WSGI, see ./run_gunicorn.py for the alternative
+#
# Please note, running with host set externally below combined with
# debug mode is a security risk unless you have a firewall setup, e.g.
#
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():
diff --git a/wqflask/wsgi.py b/wqflask/wsgi.py
new file mode 100644
index 00000000..be9c7b37
--- /dev/null
+++ b/wqflask/wsgi.py
@@ -0,0 +1,4 @@
+from run_gunicorn import app as application # expect application as a name
+
+if __name__ == "__main__":
+ application.run()