view foodtruck/main.py @ 602:c6bc0ef03f82

admin: Better UI for publishing websites. * Support multiple publish targets. * Dedicated UI for publishing. * Some UI polish.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 27 Jan 2016 18:02:25 -0800
parents d7baac1d01e6
children 200c7063affa
line wrap: on
line source

import logging


logger = logging.getLogger(__name__)


def run_foodtruck(debug=False):
    if debug:
        import foodtruck.settings
        foodtruck.settings.DEBUG = debug

    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 . import pubutil
        logger.debug("Shutting down SSE generators from main...")
        pubutil.server_shutdown = True
        raise