Mercurial > piecrust2
changeset 135:50b65c700c96
Don't use Werkzeug's reloader in non-debug mode unless we ask for it.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 25 Nov 2014 22:37:06 -0800 |
parents | 742009d964ef |
children | 1d8de8a349be |
files | piecrust/commands/builtin/serving.py piecrust/serving.py |
diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/commands/builtin/serving.py Tue Nov 25 22:36:40 2014 -0800 +++ b/piecrust/commands/builtin/serving.py Tue Nov 25 22:37:06 2014 -0800 @@ -19,12 +19,16 @@ parser.add_argument('-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') def run(self, ctx): server = Server( ctx.app.root_dir, host=ctx.args.address, port=ctx.args.port, - debug=ctx.args.debug) + debug=ctx.args.debug, + use_reloader=ctx.args.use_reloader) server.run()
--- a/piecrust/serving.py Tue Nov 25 22:36:40 2014 -0800 +++ b/piecrust/serving.py Tue Nov 25 22:37:06 2014 -0800 @@ -53,12 +53,13 @@ class Server(object): def __init__(self, root_dir, host='localhost', port='8080', - debug=False, static_preview=True, + debug=False, use_reloader=False, static_preview=True, synchronous_asset_pipeline=True): self.root_dir = root_dir self.host = host self.port = port self.debug = debug + sefl.use_reloader = use_reloader or debug self.static_preview = static_preview self.synchronous_asset_pipeline = synchronous_asset_pipeline self._out_dir = None @@ -86,7 +87,7 @@ # Run the WSGI app. wsgi_wrapper = WsgiServer(self) run_simple(self.host, self.port, wsgi_wrapper, - use_debugger=True, use_reloader=True) + use_debugger=self.debug, use_reloader=self.debug) def _run_request(self, environ, start_response): try: