From 837ce8b9c779b1da6e4390220ccd353b289c1fca Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 20 Dec 2017 09:11:31 -0600 Subject: Bring in some earlier work - mostly documentation and startup handling --- etc/default_settings.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'etc') diff --git a/etc/default_settings.py b/etc/default_settings.py index c00f6c8f..59e22f1a 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -2,7 +2,7 @@ # webserver running in developer mode with limited console # output. Copy this file and run it from ./bin/genenetwork2 configfile # -# Note that these settings are fetched in ./wqflask/utilities/tools.py +# Note: these settings are fetched in ./wqflask/utilities/tools.py # which has support for overriding them through environment variables, # e.g. # @@ -14,8 +14,12 @@ # Note also that in the near future we will additionally fetch # settings from a JSON file # -# Note that values for False and 0 have to be strings here - otherwise +# Note: values for False and 0 have to be strings here - otherwise # Flask won't pick them up +# +# For GNU Guix deployment also check the paths in +# +# ~/.guix-profile/lib/python2.7/site-packages/genenetwork2-2.0-py2.7.egg/etc/default_settings.py import os import sys @@ -34,7 +38,7 @@ SECURITY_RECOVERABLE = True SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" SECURITY_POST_LOGIN_VIEW = "/thank_you" -SERVER_PORT = 5003 +SERVER_PORT = 5003 # running on localhost SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a\xbc\xfc\x80:*\xebc' # ---- Behavioural settings (defaults) note that logger and log levels can @@ -42,6 +46,7 @@ SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a WEBSERVER_MODE = 'DEV' # Python webserver mode (DEBUG|DEV|PROD) WEBSERVER_BRANDING = None # Set the branding (nyi) WEBSERVER_DEPLOY = None # Deployment specifics (nyi) +WEBSERVER_URL = "http://localhost:"+str(SERVER_PORT)+"/" # external URL LOG_LEVEL = 'WARNING' # Logger mode (DEBUG|INFO|WARNING|ERROR|CRITICAL) LOG_LEVEL_DEBUG = '0' # logger.debugf log level (0-5, 5 = show all) -- cgit v1.2.3 From a2325f723052ff951200020f9b072a2dd5140c01 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 20 Dec 2017 10:14:35 -0600 Subject: VERSION --- VERSION | 2 +- etc/VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 120000 VERSION (limited to 'etc') diff --git a/VERSION b/VERSION deleted file mode 100644 index 6a5fe6e8..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.11 diff --git a/VERSION b/VERSION new file mode 120000 index 00000000..a9a7884c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +etc/VERSION \ No newline at end of file diff --git a/etc/VERSION b/etc/VERSION index 1785aa28..b624c74a 100644 --- a/etc/VERSION +++ b/etc/VERSION @@ -1 +1 @@ -2.10rc3 +2.10rc5 -- cgit v1.2.3 From 85316a82ec5df2c155f3c4d1dfd3739acf3d4145 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 29 Jan 2018 11:11:02 +0000 Subject: Bumped version --- etc/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'etc') 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 -- cgit v1.2.3 From 85819dbeaf922456dc205e482e7e338952945d9b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 29 Jan 2018 15:10:09 +0000 Subject: Gunicorn works --- bin/genenetwork2 | 28 +++++++++++++++++++--------- etc/default_settings.py | 2 +- wqflask/gunicorn/__init__.py | 0 wqflask/gunicorn/genenetwork2.py | 10 ---------- wqflask/gunicorn/wsgi.py | 5 ----- wqflask/run_gunicorn.py | 19 +++++++++++++++++++ wqflask/runserver.py | 2 +- wqflask/wsgi.py | 4 ++++ 8 files changed, 44 insertions(+), 26 deletions(-) delete mode 100644 wqflask/gunicorn/__init__.py delete mode 100644 wqflask/gunicorn/genenetwork2.py delete mode 100644 wqflask/gunicorn/wsgi.py create mode 100644 wqflask/run_gunicorn.py create mode 100644 wqflask/wsgi.py (limited to 'etc') diff --git a/bin/genenetwork2 b/bin/genenetwork2 index f32c76eb..f6ae3807 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -31,7 +31,7 @@ # # env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ./etc/default_settings.py -gunicorn "--bind 0.0.0.0:8000 --workers=2 --chdir wqflask/gunicorn/ wsgi" -SCRIPT=$(readlink -f "$0") +SCRIPT=$(realpath "$0") GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT")) GN2_ID=$(cat /etc/hostname):$(basename $GN2_BASE_DIR) @@ -50,15 +50,25 @@ 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 -ext="${settings##*.}" -if [ -z "$settings" -o "$ext" = "json" -o "$ext" = "JSON" ]; then - overrides=$settings +settings=$(realpath "$1") +if [ ! -e $settings ]; then settings=$GN2_BASE_DIR/etc/default_settings.py else shift fi + +ext="${settings##*.}" +if [ "$ext" = "json" -o "$ext" = "JSON" ]; then + overrides=$settings +else + echo $settings +fi + if [ ! -e $settings ]; then echo "ERROR: can not locate settings file - pass it in the command line" exit 1 @@ -132,12 +142,12 @@ if [ "$1" = '-c' ] ; then exit 0 fi if [ "$1" = '-gunicorn' ] ; then - cd $GN2_BASE_DIR - cmd=${2} + cd $GN2_BASE_DIR/wqflask + cmd=$2 echo PYTHONPATH=$PYTHONPATH - echo RUNNING COMMAND gunicorn $cmd + echo RUNNING gunicorn $cmd gunicorn $cmd - exit 0 + exit $? fi echo "Starting the redis server:" 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/gunicorn/__init__.py b/wqflask/gunicorn/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/wqflask/gunicorn/genenetwork2.py b/wqflask/gunicorn/genenetwork2.py deleted file mode 100644 index afbdc934..00000000 --- a/wqflask/gunicorn/genenetwork2.py +++ /dev/null @@ -1,10 +0,0 @@ -from flask import Flask -application = Flask(__name__) - -@application.route("/") -def hello(): - return "

Hello There!

" - -if __name__ == "__main__": - application.run(host='0.0.0.0') - diff --git a/wqflask/gunicorn/wsgi.py b/wqflask/gunicorn/wsgi.py deleted file mode 100644 index 8c14ee6b..00000000 --- a/wqflask/gunicorn/wsgi.py +++ /dev/null @@ -1,5 +0,0 @@ -from genenetwork2 import application - -if __name__ == "__main__": - application.run() - 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 "

Hello There!

" + +if __name__ == "__main__": + app.run(host='0.0.0.0') diff --git a/wqflask/runserver.py b/wqflask/runserver.py index e62e34f2..a0c76e51 100644 --- a/wqflask/runserver.py +++ b/wqflask/runserver.py @@ -1,6 +1,6 @@ # Starts the webserver with the ./bin/genenetwork2 command # -# This uses Werkzeug WSGI, see gunicorn.py for the alternative +# 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/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() -- cgit v1.2.3