Remove Paste#http, Paste#urlmap and Paste#static dependencies.
authorBerker Peksag <berker.peksag@gmail.com>
Sun, 29 Jun 2014 01:23:50 +0000 (04:23 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Sun, 29 Jun 2014 01:23:50 +0000 (04:23 +0300)
Changes:

* Paste#http -> Gunicorn
* Paste#urlmap and Paste#static -> werkzeug.wsgi.SharedDataMiddleware

lazystarter.sh
mediagoblin/app.py
paste.ini

index d3770194cd33059eab1e28e950fd3d53dfd3c30b..2842d5d57a9656876e9e3202c37e1e762a3a0bc4 100755 (executable)
@@ -20,7 +20,7 @@ selfname=$(basename "$0")
 local_bin="./bin"
 case "$selfname" in
     lazyserver.sh)
-        starter_cmd=paster
+        starter_cmd=gunicorn
         ini_prefix=paste
         ;;
     lazycelery.sh)
@@ -36,9 +36,8 @@ esac
 if [ "$1" = "-h" ]; then
     echo "$0 [-h] [-c filename.ini] [ARGS_to_${starter_cmd} ...]"
     echo ""
-    echo "   For example:"
-    echo "         $0 -c fcgi.ini port_number=23371"
-    echo "     or: $0 --server-name=fcgi --log-file=paste.log"
+    echo "   For Gunicorn settings, see at:"
+    echo "      http://docs.gunicorn.org/en/19.0/settings.html"
     echo ""
     echo "   The configfile defaults to ${ini_prefix}_local.ini,"
     echo "   if that is readable, otherwise ${ini_prefix}.ini."
@@ -71,7 +70,7 @@ set -x
 export CELERY_ALWAYS_EAGER=true
 case "$selfname" in
     lazyserver.sh)
-        $starter serve "$ini_file" "$@" --reload
+        $starter --paste "$ini_file" "$@"
         ;;
     lazycelery.sh)
         MEDIAGOBLIN_CONFIG="${ini_file}" \
index e65e6d1044958f992591e2411056fb14697c1dd8..d912206e6b76ab71e9676581802ebf534bae112d 100644 (file)
@@ -23,6 +23,7 @@ from mediagoblin.tools.routing import endpoint_to_controller
 from werkzeug.wrappers import Request
 from werkzeug.exceptions import HTTPException
 from werkzeug.routing import RequestRedirect
+from werkzeug.wsgi import SharedDataMiddleware
 
 from mediagoblin import meddleware, __version__
 from mediagoblin.db.util import check_db_up_to_date
@@ -277,8 +278,11 @@ def paste_app_factory(global_config, **app_config):
 
     if not mediagoblin_config:
         raise IOError("Usable mediagoblin config not found.")
+    del app_config['config']
 
     mgoblin_app = MediaGoblinApp(mediagoblin_config)
+    mgoblin_app.call_backend = SharedDataMiddleware(mgoblin_app.call_backend,
+                                                    exports=app_config)
     mgoblin_app = hook_transform('wrap_wsgi', mgoblin_app)
 
     return mgoblin_app
index 3c7eb177921cf990da5050cb1f50ee6ec2eea518..b859251e460e2445735ed6828dafcd1e334b5c18 100644 (file)
--- a/paste.ini
+++ b/paste.ini
@@ -6,19 +6,16 @@
 debug = false
 
 [pipeline:main]
-pipeline = errors routing
-
-[composite:routing]
-use = egg:Paste#urlmap
-/ = mediagoblin
-/mgoblin_media/ = publicstore_serve
-/mgoblin_static/ = mediagoblin_static
-/theme_static/ = theme_static
-/plugin_static/ = plugin_static
+pipeline = errors mediagoblin
 
 [app:mediagoblin]
 use = egg:mediagoblin#app
 config = %(here)s/mediagoblin_local.ini %(here)s/mediagoblin.ini
+# static paths
+/mgoblin_media = %(here)s/user_dev/media/public
+/mgoblin_static = %(here)s/mediagoblin/static
+/theme_static = %(here)s/user_dev/theme_static
+/plugin_static = %(here)s/user_dev/plugin_static
 
 [loggers]
 keys = root
@@ -42,26 +39,6 @@ formatter = generic
 [formatter_generic]
 format = %(asctime)s %(levelname)-7.7s [%(name)s] %(message)s
 
-[app:publicstore_serve]
-use = egg:Paste#static
-document_root = %(here)s/user_dev/media/public/
-cache_max_age = 604800
-
-[app:mediagoblin_static]
-use = egg:Paste#static
-document_root = %(here)s/mediagoblin/static/
-cache_max_age = 86400
-
-[app:theme_static]
-use = egg:Paste#static
-document_root = %(here)s/user_dev/theme_static/
-cache_max_age = 86400
-
-[app:plugin_static]
-use = egg:Paste#static
-document_root = %(here)s/user_dev/plugin_static/
-cache_max_age = 86400
-
 [filter:errors]
 use = egg:mediagoblin#errors
 debug = false
@@ -74,30 +51,11 @@ debug = false
 # The server that is run by default.
 # By default, should only be accessable locally
 [server:main]
-use = egg:Paste#http
+use = egg:gunicorn
 host = 127.0.0.1
 port = 6543
-
-#######################
-# Helper server configs
-# ---------------------
-#   If you are configuring the paste config manually, you can remove
-#   these.
-
-# Use this if you want to run on port 6543 and have MediaGoblin be
-# viewable externally
-[server:broadcast]
-use = egg:Paste#http
-host = 0.0.0.0
-port = 6543
-
-# Use this if you want to connect via fastcgi
-[server:fcgi]
-use = egg:flup#fcgi_fork
-host = %(fcgi_host)s
-port = %(fcgi_port)s
-
-[server:http]
-use = egg:Paste#http
-host = %(http_host)s
-port = %(http_port)s
+# Gunicorn settings. See http://docs.gunicorn.org/en/19.0/settings.html
+# for more information about configuring Gunicorn
+proc_name = gmg
+reload = true
+accesslog = -