diff piecrust/admin/main.py @ 778:5e91bc0e3b4d

internal: Move admin panel code into the piecrust package.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 16 Jul 2016 15:02:24 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/admin/main.py	Sat Jul 16 15:02:24 2016 +0200
@@ -0,0 +1,26 @@
+import logging
+
+
+logger = logging.getLogger(__name__)
+
+
+def run_foodtruck(host=None, port=None, debug=False, extra_settings=None):
+    es = {}
+    if debug:
+        es['DEBUG'] = True
+    if extra_settings:
+        es.update(extra_settings)
+
+    from .web import create_foodtruck_app
+    try:
+        app = create_foodtruck_app(es)
+        app.run(host=host, port=port, debug=debug, threaded=True)
+    except SystemExit:
+        # This is needed for Werkzeug's code reloader to be able to correctly
+        # shutdown the child process in order to restart it (otherwise, SSE
+        # generators will keep it alive).
+        from . import pubutil
+        logger.debug("Shutting down SSE generators from main...")
+        pubutil.server_shutdown = True
+        raise
+