diff --git a/cerulean_cloud/cloud_run_tipg/handler.py b/cerulean_cloud/cloud_run_tipg/handler.py index 7d41fa90..9c16a740 100644 --- a/cerulean_cloud/cloud_run_tipg/handler.py +++ b/cerulean_cloud/cloud_run_tipg/handler.py @@ -10,6 +10,7 @@ """ import logging +import warnings from typing import Any, List, Optional import jinja2 @@ -109,20 +110,24 @@ class Config: @app.on_event("startup") async def startup_event() -> None: """Connect to database on startup.""" - await connect_to_db(app, settings=postgres_settings) - assert getattr(app.state, "pool", None) - - await register_collection_catalog( - app, - schemas=db_settings.schemas, - exclude_table_schemas=db_settings.exclude_table_schemas, - tables=db_settings.tables, - exclude_tables=db_settings.exclude_tables, - exclude_function_schemas=db_settings.exclude_function_schemas, - functions=db_settings.functions, - exclude_functions=db_settings.exclude_functions, - spatial=False, # False means allow non-spatial tables - ) + try: + await connect_to_db(app, settings=postgres_settings) + assert getattr(app.state, "pool", None) + + await register_collection_catalog( + app, + schemas=db_settings.schemas, + exclude_table_schemas=db_settings.exclude_table_schemas, + tables=db_settings.tables, + exclude_tables=db_settings.exclude_tables, + exclude_function_schemas=db_settings.exclude_function_schemas, + functions=db_settings.functions, + exclude_functions=db_settings.exclude_functions, + spatial=False, # False means allow non-spatial tables + ) + except: # noqa + warnings.warn("Could not initiate TiPg", UserWarning) + pass @app.on_event("shutdown")