app/mailman-web: create

There's a lot of ugly hacks here, but this has been the state of prod
for months now, so we should reflect that.
Also, this bumps a bunch of workspace deps.

Change-Id: I744e0d3aff27036cfed73416cf442c7d62444a8b
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1473
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/app/mailman-web/serve.py b/app/mailman-web/serve.py
new file mode 100644
index 0000000..e56bd04
--- /dev/null
+++ b/app/mailman-web/serve.py
@@ -0,0 +1,38 @@
+import os
+import gunicorn.app.base
+from django.core.wsgi import get_wsgi_application
+
+
+class StandaloneApplication(gunicorn.app.base.BaseApplication):
+
+    def __init__(self, app, options=None):
+        self.options = options or {}
+        self.application = app
+        super().__init__()
+
+    def load_config(self):
+        config = {key: value for key, value in self.options.items()
+                  if key in self.cfg.settings and value is not None}
+        for key, value in config.items():
+            self.cfg.set(key.lower(), value)
+
+    def load(self):
+        return self.application
+
+
+def main():
+    options = {
+        'bind': os.environ.get('BIND_ADDR', '127.0.0.1:8080'),
+        'workers': int(os.environ.get("GUNICORN_WORKERS", "4")),
+        'capture_output': True,
+        'disable_redirect_access_to_syslog': True,
+        'accesslog': '-',
+        'errorlog': '-',
+    }
+    os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
+    application = get_wsgi_application()
+    StandaloneApplication(application, options).run()
+
+
+if __name__ == '__main__':
+    main()