Switch from Paste for serving to Waitress
Incredibly, it looks like none of our documentation has to change taking this route...!
This commit is contained in:
parent
149f46f7d5
commit
d61778a489
@ -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
|
||||
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 ""
|
||||
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
|
||||
;;
|
||||
lazycelery.sh)
|
||||
MEDIAGOBLIN_CONFIG="${ini_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)
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
19
paste.ini
19
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
|
||||
|
5
setup.py
5
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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user