view foodtruck/main.py @ 774:2bb3c1a04e98

prepare: Add ablity to run an editor program after creating the page file.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 03 Jul 2016 16:44:18 -0700
parents 3885421c29a3
children
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 create_foodtruck_app
    try:
        app = create_foodtruck_app()
        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