scout/commands/serve.py
def serve(context, config, host, port, debug, livereload):
    """Start the web server."""
    pymongo_config = dict(
        MONGO_HOST=context.obj['host'],
        MONGO_PORT=context.obj['port'],
        MONGO_DBNAME=context.obj['mongodb'],
        MONGO_USERNAME=context.obj['username'],
        MONGO_PASSWORD=context.obj['password'],
    )
    
    valid_connection = check_connection(
        host=pymongo_config['MONGO_HOST'], 
        port=pymongo_config['MONGO_PORT'], 
        username=pymongo_config['MONGO_USERNAME'], 
        password=pymongo_config['MONGO_PASSWORD'],
        authdb=context.obj['authdb'],
        )

    log.info("Test if mongod is running")
    if not valid_connection:
        log.warning("Connection could not be established")
        log.info("Is mongod running?")
        context.abort()
    

    config = os.path.abspath(config) if config else None
    app = create_app(config=pymongo_config, config_file=config)
    if livereload:
        server = Server(app.wsgi_app)
        server.serve(host=host, port=port, debug=debug)
    else:
        app.run(host=host, port=port, debug=debug)
def serve(context, config, host, port, debug, livereload):
    """Start the web server."""
    pymongo_config = dict(
        MONGO_HOST=context.obj['host'],
        MONGO_PORT=context.obj['port'],
        MONGO_DBNAME=context.obj['mongodb'],
        MONGO_USERNAME=context.obj['username'],
        MONGO_PASSWORD=context.obj['password'],
    )
    
    valid_connection = check_connection(
        host=pymongo_config['MONGO_HOST'], 
        port=pymongo_config['MONGO_PORT'], 
        username=pymongo_config['MONGO_USERNAME'], 
        password=pymongo_config['MONGO_PASSWORD'],
        authdb=context.obj['authdb'],
        )

    log.info("Test if mongod is running")
    if not valid_connection:
        log.warning("Connection could not be established")
        log.info("Is mongod running?")
        context.abort()
    

    config = os.path.abspath(config) if config else None
    app = create_app(config=pymongo_config, config_file=config)
    if livereload:
        server = Server(app.wsgi_app)
        server.serve(host=host, port=port, debug=debug)
    else:
        app.run(host=host, port=port, debug=debug)
Start the web server.