aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2018-01-29 14:15:49 +0000
committerPjotr Prins2018-01-29 14:15:49 +0000
commitb3724d60d2e50dd19e61140406aa85dff981ac16 (patch)
tree23dc1db8f3bc192aa40c77ae492033aed5787423
parent06b203e722c0061aae6c16f877619dc7af03638e (diff)
downloadgenenetwork2-b3724d60d2e50dd19e61140406aa85dff981ac16.tar.gz
startup script: adapting for gunicorn
-rwxr-xr-xbin/genenetwork216
-rw-r--r--wqflask/__init__.py1
-rw-r--r--wqflask/gunicorn/__init__.py0
-rw-r--r--wqflask/gunicorn/genenetwork2.py10
-rw-r--r--wqflask/gunicorn/wsgi.py5
-rw-r--r--wqflask/runserver.py2
6 files changed, 33 insertions, 1 deletions
diff --git a/bin/genenetwork2 b/bin/genenetwork2
index c6b08771..f32c76eb 100755
--- a/bin/genenetwork2
+++ b/bin/genenetwork2
@@ -22,6 +22,14 @@
# 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 production we use gunicorn. Run with
+#
+# 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")
GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT"))
@@ -123,6 +131,14 @@ if [ "$1" = '-c' ] ; then
python $cmd
exit 0
fi
+if [ "$1" = '-gunicorn' ] ; then
+ cd $GN2_BASE_DIR
+ cmd=${2}
+ echo PYTHONPATH=$PYTHONPATH
+ echo RUNNING COMMAND gunicorn $cmd
+ gunicorn $cmd
+ exit 0
+fi
echo "Starting the redis server:"
echo -n "dir $TMPDIR
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/gunicorn/__init__.py b/wqflask/gunicorn/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/gunicorn/__init__.py
diff --git a/wqflask/gunicorn/genenetwork2.py b/wqflask/gunicorn/genenetwork2.py
new file mode 100644
index 00000000..afbdc934
--- /dev/null
+++ b/wqflask/gunicorn/genenetwork2.py
@@ -0,0 +1,10 @@
+from flask import Flask
+application = Flask(__name__)
+
+@application.route("/")
+def hello():
+ return "<h1 style='color:blue'>Hello There!</h1>"
+
+if __name__ == "__main__":
+ application.run(host='0.0.0.0')
+
diff --git a/wqflask/gunicorn/wsgi.py b/wqflask/gunicorn/wsgi.py
new file mode 100644
index 00000000..8c14ee6b
--- /dev/null
+++ b/wqflask/gunicorn/wsgi.py
@@ -0,0 +1,5 @@
+from genenetwork2 import application
+
+if __name__ == "__main__":
+ application.run()
+
diff --git a/wqflask/runserver.py b/wqflask/runserver.py
index 50f134db..e62e34f2 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 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.
#