From: Christopher Allan Webber Date: Thu, 18 Feb 2016 01:39:32 +0000 (-0800) Subject: Switch from Paste for serving to Waitress X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d61778a489f606f1bff4f01f250a0e3c4fb99e27;p=mediagoblin.git Switch from Paste for serving to Waitress Incredibly, it looks like none of our documentation has to change taking this route...! --- diff --git a/lazystarter.sh b/lazystarter.sh index 98362794..0ed22fd8 100755 --- a/lazystarter.sh +++ b/lazystarter.sh @@ -19,34 +19,9 @@ 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}" \ diff --git a/mediagoblin/app.py b/mediagoblin/app.py index b9846962..345aa048 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -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) diff --git a/mediagoblin/gmg_commands/serve.py b/mediagoblin/gmg_commands/serve.py index 64400fdd..6ded1cfc 100644 --- a/mediagoblin/gmg_commands/serve.py +++ b/mediagoblin/gmg_commands/serve.py @@ -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): diff --git a/mediagoblin/tests/test_paste.ini b/mediagoblin/tests/test_paste.ini index 8d75c3cb..1c5f09fa 100644 --- a/mediagoblin/tests/test_paste.ini +++ b/mediagoblin/tests/test_paste.ini @@ -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 diff --git a/paste.ini b/paste.ini index 68fd9dea..ce3f01e8 100644 --- 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 diff --git a/setup.py b/setup.py index bae0a52c..9cd63b05 100644 --- 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',