Switch from Paste for serving to Waitress
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 18 Feb 2016 01:39:32 +0000 (17:39 -0800)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 19 Feb 2016 18:22:14 +0000 (10:22 -0800)
Incredibly, it looks like none of our documentation has to change taking
this route...!

lazystarter.sh
mediagoblin/app.py
mediagoblin/gmg_commands/serve.py
mediagoblin/tests/test_paste.ini
paste.ini
setup.py

index 98362794561bbaddba28afa7ee418bfbb4fbaee1..0ed22fd8a00b9d3c88bf09731ee36a0ad48dd950 100755 (executable)
 selfname=$(basename "$0")
 local_bin="./bin"
 
-# Test whether or not gunicorn is installed
-# -----------------------------------------
-if [ -f "${local_bin}/python" ]; then
-    our_python="${local_bin}/python";
-else
-    our_python="python";
-fi
-
-if $our_python -c "import sys
-try:
-    import gunicorn
-    sys.exit(0)
-except ImportError:
-    sys.exit(1)
-"; then
-    use_gunicorn=true;
-else
-    use_gunicorn=false;
-fi
-# -----------------------------------------
-
 case "$selfname" in
     lazyserver.sh)
-        if $use_gunicorn; then
-            starter_cmd=gunicorn;
-        else
-            starter_cmd=paster;
-        fi
+        starter_cmd=paster;
         ini_prefix=paste
         ;;
     lazycelery.sh)
@@ -62,14 +37,9 @@ esac
 if [ "$1" = "-h" ]; then
     echo "$0 [-h] [-c filename.ini] [ARGS_to_${starter_cmd} ...]"
     echo ""
-    if $use_gunicorn; then
-        echo "   For Gunicorn settings, see at:"
-        echo "      http://docs.gunicorn.org/en/19.0/settings.html"
-    else
-        echo "   For example:"
-        echo "         $0 -c fcgi.ini port_number=23371"
-        echo "     or: $0 --server-name=fcgi --log-file=paste.log"
-    fi
+    echo "   For example:"
+    echo "         $0 -c fcgi.ini port_number=23371"
+    echo "     or: $0 --server-name=fcgi --log-file=paste.log"
     echo ""
     echo "   The configfile defaults to ${ini_prefix}_local.ini,"
     echo "   if that is readable, otherwise ${ini_prefix}.ini."
@@ -112,11 +82,7 @@ set -x
 export CELERY_ALWAYS_EAGER=true
 case "$selfname" in
     lazyserver.sh)
-        if $use_gunicorn; then
-            $starter --paste "$ini_file" --log-file=- $@;
-        else
-            $starter serve "$ini_file" "$@" --reload;
-        fi
+        $starter serve "$ini_file" "$@" --reload;
         ;;
     lazycelery.sh)
         MEDIAGOBLIN_CONFIG="${ini_file}" \
index b98469625e74cc732814b911e29a71ad64b96c55..345aa048dd70a36de5a18585e36de7a68a702752 100644 (file)
@@ -365,34 +365,3 @@ def paste_app_factory(global_config, **app_config):
     mgoblin_app = hook_transform('wrap_wsgi', mgoblin_app)
 
     return mgoblin_app
-
-
-def paste_server_selector(wsgi_app, global_config=None, **app_config):
-    """
-    Select between gunicorn and paste depending on what ia available
-    """
-    # See if we can import the gunicorn server...
-    # otherwise we'll use the paste server
-    try:
-        import gunicorn
-    except ImportError:
-        gunicorn = None
-
-    if gunicorn is None:
-        # use paste
-        from paste.httpserver import server_runner
-
-        cleaned_app_config = dict(
-            [(key, app_config[key])
-             for key in app_config
-             if key in ["host", "port", "handler", "ssl_pem", "ssl_context",
-                        "server_version", "protocol_version", "start_loop",
-                        "daemon_threads", "socket_timeout", "use_threadpool",
-                        "threadpool_workers", "threadpool_options",
-                        "request_queue_size"]])
-
-        return server_runner(wsgi_app, global_config, **cleaned_app_config)
-    else:
-        # use gunicorn
-        from gunicorn.app.pasterapp import PasterServerApplication
-        return PasterServerApplication(wsgi_app, global_config, **app_config)
index 64400fdd5eaca2897225e1199b868e8d3ab4e9f0..6ded1cfc63cdc9feeec1830ed41f9042ec8a2eb8 100644 (file)
@@ -29,7 +29,6 @@ class ServeCommand(object):
         return loadapp(app_spec, name=name, relative_to=relative_to, **kwargs)
 
     def daemonize(self):
-        # TODO: pass to gunicorn if available
         pass
 
     def restart_with_reloader(self):
index 8d75c3cb3076c23865a7527ddd19b8f4c2851073..1c5f09fadf1f6dae96a63462578f72eb70002279 100644 (file)
@@ -13,6 +13,6 @@ config = %(here)s/mediagoblin.ini
 CELERY_ALWAYS_EAGER = true
 
 [server:main]
-use = egg:gunicorn
+use = egg:waitress#main
 host = 127.0.0.1
 port = 6543
index 68fd9dea43c889ec256b29536368902a8e1ddb99..ce3f01e85d7b8e8d0a47cd5a984151cd46d1b047 100644 (file)
--- a/paste.ini
+++ b/paste.ini
@@ -6,7 +6,8 @@
 debug = false
 
 [pipeline:main]
-pipeline = errors mediagoblin
+# pipeline = errors mediagoblin
+pipeline = mediagoblin
 
 [app:mediagoblin]
 use = egg:mediagoblin#app
@@ -51,14 +52,14 @@ debug = false
 # The server that is run by default.
 # By default, should only be accessable locally
 [server:main]
-use = egg:mediagoblin#paste_server_selector
+use = egg:waitress#main
 host = 127.0.0.1
 port = 6543
-# Gunicorn settings. See http://docs.gunicorn.org/en/19.0/settings.html
-# for more information about configuring Gunicorn
-proc_name = gmg
-reload = true
-accesslog = -
+# Gunicorn settings. See http://docs.gunicorn.org/en/19.0/settings.html
+# for more information about configuring Gunicorn
+proc_name = gmg
+reload = true
+accesslog = -
 
 #######################
 # Helper server configs
@@ -69,7 +70,7 @@ accesslog = -
 # Use this if you want to run on port 6543 and have MediaGoblin be
 # viewable externally
 [server:broadcast]
-use = egg:Paste#http
+use = egg:waitress#main
 host = 0.0.0.0
 port = 6543
 
@@ -80,6 +81,6 @@ host = %(fcgi_host)s
 port = %(fcgi_port)s
 
 [server:http]
-use = egg:Paste#http
+use = egg:waitress#main
 host = %(http_host)s
 port = %(http_port)s
index bae0a52c92a2752bbf82abec03e71c186a0ad470..9cd63b05f5c6cc10b8589d163abd632c5fe7bf81 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -43,16 +43,13 @@ def get_version():
 pyversion_install_requires = []
 if PY2:
     pyversion_install_requires.append('argparse')  # only for < 2.7
-    pyversion_install_requires.append('PasteScript')
     pyversion_install_requires.append('sqlalchemy-migrate>=0.9.6')
     pyversion_install_requires.append('mock==1.0.1')  # mock is in the stdlib for 3.3+
     # PyPI version (1.4.2) does not have proper Python 3 support
     pyversion_install_requires.append('ExifRead')
-    pyversion_install_requires.append('Paste')
-else:
-    pyversion_install_requires.append('gunicorn')
 
 install_requires = [
+    'waitress',
     'alembic==0.6.6',
     'python-dateutil',
     'wtforms',