forked from mirrors/thatmattlove-hyperglass
fix startup/shutdown event handling
This commit is contained in:
parent
5fe4c6a0f0
commit
6780c2fd87
2 changed files with 9 additions and 4 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue