view foodtruck/main.py @ 597:79a31a3c947b

admin: Better production config for FoodTruck, provide proper first site. * Use a `settings` object to configure Flask. * Accept an `app.cfg` file in the admin folder to configure Flask. * Get a proper first site name when the cookie isn't set yet.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Jan 2016 21:39:18 -0800
parents b884bef3e611
children d7baac1d01e6
line wrap: on
line source

import logging


logger = logging.getLogger(__name__)


def run_foodtruck(debug=False):
    from .web import app
    try:
        app.run(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 .views import baking
        logger.debug("Shutting down SSE generators from main...")
        baking.server_shutdown = True
        raise