changeset 252:3e6f82347eab

uwsgi bits
author Matt Johnston <matt@ucc.asn.au>
date Sat, 06 Jun 2015 15:34:03 +0800
parents 141948a400a6
children 8ef52f27cf95
files web/requirements.txt web/templog-uwsgi.ini web/templog.py web/templog.uwsgi
diffstat 4 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/requirements.txt	Sat Jun 06 15:34:03 2015 +0800
@@ -0,0 +1,11 @@
+argparse==1.2.1
+gevent==1.0.2
+greenlet==0.4.7
+
+# sha256: nkIlLxfR3YnuMXReDE--WIYsJRR-sO9SlcnNm8tOosE
+lockfile==0.10.2
+
+peep==2.4.1
+python-rrdtool==1.4.7
+uWSGI==2.0.10
+wsgiref==0.1.2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/templog-uwsgi.ini	Sat Jun 06 15:34:03 2015 +0800
@@ -0,0 +1,15 @@
+[uwsgi]
+
+# run with "/path/to/venv/bin/uwsgi --chdir /path/to/web /path/to/web/templog.uwsgi"
+# tested with Apache mod_proxy_uwsgi and 
+# ProxyPass /~matt/t2 uwsgi://127.0.0.1:9090/
+
+# future: apache > 2.4.9 could use "socket=uwsgi.sock" and then apache config of
+# ProxyPass /templog unix:/path/to/web/uwsgi.sock|uwsgi://
+socket=127.0.0.1:9090
+
+wsgi-file=templog.uwsgi
+gevent=100
+
+# for client certificates. default limit is 4096, not sufficient
+buffer-size=20000
--- a/web/templog.py	Wed May 27 23:45:03 2015 +0800
+++ b/web/templog.py	Sat Jun 06 15:34:03 2015 +0800
@@ -159,12 +159,18 @@
     #var_lookup = environ['mod_ssl.var_lookup']
     #return var_lookup("SSL_SERVER_I_DN_O")
 
+@route('/wait')
+def wait():
+    response.set_header('Content-Type', 'text/plain')
+    yield 'done'
+
 @bottle.get('/<filename:re:.*\.js>')
 def javascripts(filename):
     response.set_header('Cache-Control', "public, max-age=1296000")
     return bottle.static_file(filename, root='static')
 
 def main():
+    """ for standalone testing """
     #bottle.debug(True)
     #bottle.run(reloader=True)
     bottle.run(server='cgi', reloader=True)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/templog.uwsgi	Sat Jun 06 15:34:03 2015 +0800
@@ -0,0 +1,20 @@
+# see templog-uwsgi.ini for arguments
+
+from gevent import monkey; monkey.patch_all()
+
+import os
+import sys
+import trace
+# Change working directory so relative paths (and template lookup) work again
+thisdir = os.path.dirname(__file__)
+if not thisdir:
+    thisdir="."
+os.chdir(thisdir)
+os.environ['LD_LIBRARY_PATH'] = '/home/matt/templog/web'
+
+# for some reason local imports don't work...
+sys.path.append(thisdir)
+
+import bottle
+import templog
+application = bottle.default_app()