Add example files for running clipperz with uwsgi and nginx

Additionally make changes to enable running clipperz from uwsgi
This commit is contained in:
jokajak 2016-04-24 08:35:37 -04:00
parent 72aa4ecfb6
commit 3574eacb25
4 changed files with 60 additions and 4 deletions

View File

@ -1,10 +1,11 @@
"""Clipperz views."""
from flask import session, request, g
from flask import session, request, g, send_from_directory
from clipperz import app, db, lm
from .models import User
from .api import * # NOQA
from .exceptions import InvalidUsage
from flask.ext.login import login_required
from os.path import dirname
@lm.user_loader
@ -113,19 +114,25 @@ def dump(frontend_version):
@app.route('/beta/<path:path>')
def beta(path):
"""Fallback for serving beta version."""
return send_from_directory('beta', path)
here = dirname(__file__)
file_path = "{0}/../beta/".format(here)
return send_from_directory(file_path, path)
@app.route('/gamma/<path:path>')
def gamma(path):
"""Fallback for serving gamma version."""
return send_from_directory('gamma', path)
here = dirname(__file__)
file_path = "{0}/../gamma/".format(here)
return send_from_directory(file_path, path)
@app.route('/delta/<path:path>')
def delta(path):
"""Fallback for serving delta version."""
return send_from_directory('delta', path)
here = dirname(__file__)
file_path = "{0}/../delta/".format(here)
return send_from_directory(file_path, path)
@app.route('/pm', methods=['GET', 'OPTIONS', 'POST'])

View File

@ -0,0 +1,11 @@
location /pm {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
try_files $uri $uri/ @pm;
}
location @pm {
include uwsgi_params;
uwsgi_param SCRIPT_NAME /pm;
uwsgi_modifier1 30;
uwsgi_pass unix:/run/uwsgi/pm.sock;
}

10
backend/flask/src/run.py Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
from clipperz import app, db
def main():
db.create_all()
app.run(debug=True)
if __name__ == "__main__":
main()

View File

@ -0,0 +1,28 @@
[uwsgi]
plugin = python
socket = /run/uwsgi/%n.sock
chmod-socket = 660
master = true
processes = 1
uid = clipperz
gid = clipperz
umask = 027
procname-master = uwsgi pm
vacuum = true
die-on-term = true
base = /home/clipperz/password-manager/target/flask/
module = clipperz
callable = app
venv = /home/clipperz/password-manager/target/flask/
#the variable that holds a flask application inside the module imported at line #6
callable = app
#location of log files
logto = /var/log/uwsgi/%n.log
env = PYTHON_EGG_CACHE=/var/tmp/clipperz
env = DATABASE_URL = 'mysql://clipperz:clipperz@localhost/clipperz'