Skip to content

Failing to load catalog on startup using FastAPI lifespan #220

@ancientpi3

Description

@ancientpi3

Hello,
We are encountering an issue when trying to handle start up and shut down using a FastAPI lifespan function implementation which we based off an example in your documentation (linked below). It appears that connect_to_db() and register_collection_catalog() will fail quietly on startup. We suspect it is because our Postgres instance isn't yet ready when these functions are being called on startup.

Calling the /collections endpoint immediately after startup returns:
{"detail":"Could not find collections catalog."}

If we manually trigger the /register endpoint afterward, the collections load correctly.

Your example implementation:
https://developmentseed.org/tipg/advanced/customization/

Our implementation:
https://github.com/SkyTruth/cerulean-cloud/blob/5caa95482e261209ae4ee31d68a111322c112c21/cerulean_cloud/cloud_run_tipg/handler.py

Do you have any recommended changes for getting startup to work using FastAPI lifespan functions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions