UI_DIR = STATIC_PATH / "ui" CUSTOM_DIR = STATIC_PATH / "custom" IMAGES_DIR = STATIC_PATH / "images" EXAMPLE_DEVICES_PY = EXAMPLES_DIR / "devices.py" EXAMPLE_QUERIES_PY = EXAMPLES_DIR / "queries.py" EXAMPLE_QUERY_PY = EXAMPLES_DIR / "query.py" EXAMPLE_DEVICES_CURL = EXAMPLES_DIR / "devices.sh" EXAMPLE_QUERIES_CURL = EXAMPLES_DIR / "queries.sh" EXAMPLE_QUERY_CURL = EXAMPLES_DIR / "query.sh" ASGI_PARAMS = { "host": str(params.listen_address), "port": params.listen_port, "debug": params.debug, "workers": cpu_count(2), } DOCS_PARAMS = {} if params.docs.enable: DOCS_PARAMS.update({"openapi_url": params.docs.openapi_uri}) if params.docs.mode == "redoc": DOCS_PARAMS.update({"docs_url": None, "redoc_url": params.docs.uri}) elif params.docs.mode == "swagger": DOCS_PARAMS.update({"docs_url": params.docs.uri, "redoc_url": None}) for directory in (UI_DIR, IMAGES_DIR): if not directory.exists(): log.warning("Directory '{d}' does not exist, creating...", d=str(directory)) directory.mkdir()
raise RuntimeError(f"Python {pretty_version}+ is required.") from hyperglass.configuration import ( # isort:skip params, URL_DEV, URL_PROD, CONFIG_PATH, REDIS_CONFIG, frontend_params, ) from hyperglass.util import ( # isort:skip cpu_count, check_redis, build_frontend, clear_redis_cache, format_listen_address, ) from hyperglass.compat._asyncio import aiorun # isort:skip if params.debug: workers = 1 loglevel = "DEBUG" else: workers = cpu_count(2) loglevel = "WARNING" async def check_redis_instance(): """Ensure Redis is running before starting server. Returns: {bool} -- True if Redis is running. """ await check_redis(db=params.cache.database, config=REDIS_CONFIG) log.debug( f"Redis is running at: {REDIS_CONFIG['host']}:{REDIS_CONFIG['port']}") return True