From 58f136a559f6b868d32a93b60f2649b5be2ff42f Mon Sep 17 00:00:00 2001 From: Aubrey Bailey Date: Wed, 6 Feb 2019 10:20:16 +0200 Subject: [PATCH] updated README.md Added a section on more permanent deployment options for local intranet. I'm relatively sure that I'm the target audience for this package and I spent way too long figuring this out, so I bet someone else will appreciate it as well. --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/README.md b/README.md index 7a47ea5..3070fba 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,59 @@ Currently supported options are: USES_OAUTH - whether or not data is protected using OAuth ALLOWED_EMAILS - the filename containing the list of allowed emails when using OAuth PUBLIC_DIR - path to directory of public data when using OAuth (eg. /static/data/public) + +### Deployment +Flask is not meant to be a standalone/permanent hosting solution. +If you are intending to deploy this as an intranet service (Think carefully before exposing genomic data to an unprotected network) you may find it conveinent to route Flask through a proper web server such as Apache or Nginx. For this, Flask requires an intermediate layer which understands python such as Gunicorn or uWSGI. Gunicorn is native to python detects most settings automatically, but needs an accompanying daemon to keep it running in the background. uWSGI has native packages on most common distros, but requires a configuration such as the following. + +for debian-based distros, the following are dependencies: +``` +uwsgi-emperor uwsgi-plugin-python3 +``` + +This configuration assumes that this repository is cloned to +/srv/igvjs/igvjs +and the virtualenv is created at +/srv/igvjs/virtualenvironment + +``` +virtualenv /srv/igvjs/virtualenvironment +source /srv/igvjs/virtualenv/bin/activate +pip3 install -r /srv/igvjs/igvjs/requirements.txt +``` + +/etc/uwsgi-emperor/vassals/igv.ini +``` +[uwsgi] +plugins = python3 +project = igvjs +uid = igv +gid = www-data +base = /srv/igvjs + +chdir = %(base)/%(project) +home = %(base)/virtualenv +module = igvjs:app + +master = true +processes = 5 + +socket = /run/uwsgi/%(project).sock +mount = /igv=%(module) +vacuum = true + +; rewrite SCRIPT_NAME and PATH_INFO accordingly +manage-script-name = true +``` + +In this setup, an appropriate nginx directive would be + +``` + location /igv { + uwsgi_pass unix:///run/uwsgi/igvjs.sock; + include uwsgi_params; + } + location ^~ /static/ { + alias /srv/igvjs/igvjs/igvjs/static; + } +```