view foodtruck/main.py @ 679:15b6ffadc95f

cm: It's fun to send typos to Travis-CI.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 07 Mar 2016 00:03:13 -0800
parents 200c7063affa
children 3885421c29a3
line wrap: on
line source

import logging


logger = logging.getLogger(__name__)


def run_foodtruck(host=None, port=None, debug=False):
    if debug:
        import foodtruck.settings
        foodtruck.settings.DEBUG = debug

    from .web import app
    try:
        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