Mercurial > piecrust2
diff piecrust/commands/builtin/serving.py @ 852:4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
* Everything is a `ContentSource`, including assets directories.
* Most content sources are subclasses of the base file-system source.
* A source is processed by a "pipeline", and there are 2 built-in pipelines,
one for assets and one for pages. The asset pipeline is vaguely functional,
but the page pipeline is completely broken right now.
* Rewrite the baking process as just running appropriate pipelines on each
content item. This should allow for better parallelization.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 17 May 2017 00:11:48 -0700 |
parents | 81d9c3a3a0b5 |
children | f77f9dcba072 |
line wrap: on
line diff
--- a/piecrust/commands/builtin/serving.py Sat Apr 29 21:42:22 2017 -0700 +++ b/piecrust/commands/builtin/serving.py Wed May 17 00:11:48 2017 -0700 @@ -1,6 +1,5 @@ import logging from piecrust.commands.base import ChefCommand -from piecrust.serving.wrappers import run_werkzeug_server, run_gunicorn_server logger = logging.getLogger(__name__) @@ -15,54 +14,46 @@ def setupParser(self, parser, app): parser.add_argument( - '-p', '--port', - help="The port for the web server", - default=8080) + '-p', '--port', + help="The port for the web server", + default=8080) parser.add_argument( - '-a', '--address', - help="The host for the web server", - default='localhost') + '-a', '--address', + help="The host for the web server", + default='localhost') parser.add_argument( - '--use-reloader', - help="Restart the server when PieCrust code changes", - action='store_true') + '--use-reloader', + help="Restart the server when PieCrust code changes", + action='store_true') parser.add_argument( - '--use-debugger', - help="Show the debugger when an error occurs", - action='store_true') + '--use-debugger', + help="Show the debugger when an error occurs", + action='store_true') parser.add_argument( - '--wsgi', - help="The WSGI server implementation to use", - choices=['werkzeug', 'gunicorn'], - default='werkzeug') + '--wsgi', + help="The WSGI server implementation to use", + choices=['werkzeug', 'gunicorn'], + default='werkzeug') def run(self, ctx): - root_dir = ctx.app.root_dir host = ctx.args.address port = int(ctx.args.port) debug = ctx.args.debug or ctx.args.use_debugger - - from piecrust.app import PieCrustFactory - appfactory = PieCrustFactory( - ctx.app.root_dir, - cache=ctx.app.cache.enabled, - cache_key=ctx.app.cache_key, - config_variant=ctx.config_variant, - config_values=ctx.config_values, - debug=ctx.app.debug, - theme_site=ctx.app.theme_site) + appfactory = ctx.appfactory if ctx.args.wsgi == 'werkzeug': + from piecrust.serving.wrappers import run_werkzeug_server run_werkzeug_server( - appfactory, host, port, - use_debugger=debug, - use_reloader=ctx.args.use_reloader) + appfactory, host, port, + use_debugger=debug, + use_reloader=ctx.args.use_reloader) elif ctx.args.wsgi == 'gunicorn': + from piecrust.serving.wrappers import run_gunicorn_server options = { - 'bind': '%s:%s' % (host, port), - 'accesslog': '-', # print access log to stderr - } + 'bind': '%s:%s' % (host, port), + 'accesslog': '-', # print access log to stderr + } if debug: options['loglevel'] = 'debug' if ctx.args.use_reloader: