diff --git a/hyperglass/api/__init__.py b/hyperglass/api/__init__.py index e07968c..4df62b6 100644 --- a/hyperglass/api/__init__.py +++ b/hyperglass/api/__init__.py @@ -45,10 +45,15 @@ app = FastAPI( docs_url=None, redoc_url=None, openapi_url=params.general.docs.openapi_url, - on_shutdown=on_shutdown, - on_startup=on_startup, ) +# Add Event Handlers +for startup in on_startup: + app.add_event_handler("startup", startup) + +for shutdown in on_shutdown: + app.add_event_handler("shutdown", shutdown) + # HTTP Error Handler app.add_exception_handler(StarletteHTTPException, http_handler) diff --git a/hyperglass/api/events.py b/hyperglass/api/events.py index 6ac6f05..2eebde1 100644 --- a/hyperglass/api/events.py +++ b/hyperglass/api/events.py @@ -26,7 +26,7 @@ async def check_python_version(): python_version = check_python() log.info(f"Python {python_version} detected") except RuntimeError as r: - raise HyperglassError(str(r), alert="danger") from None + raise HyperglassError(str(r), level="danger") from None async def check_redis_instance(): @@ -41,7 +41,7 @@ async def check_redis_instance(): try: await check_redis(db=params.features.cache.redis_id, config=REDIS_CONFIG) except RuntimeError as e: - raise HyperglassError(str(e), alert="danger") from None + raise HyperglassError(str(e), level="danger") from None log.debug(f"Redis is running at: {REDIS_CONFIG['host']}:{REDIS_CONFIG['port']}") return True