Skip to content

rs_server_catalog/main.md

<< Back to index

RS-Server STAC catalog based on stac-fastapi-pgstac.

UvicornSettings

Bases: BaseSettings

Uvicorn deployment settings, read from the APP_HOST, APP_PORT and RELOAD env vars.

They were removed from the stac-fastapi ApiSettings in stac-fastapi 7.0.0, so we define them here with the same names and default values.

Source code in docs/rs-server/services/catalog/rs_server_catalog/main.py
class UvicornSettings(BaseSettings):
    """
    Uvicorn deployment settings, read from the APP_HOST, APP_PORT and RELOAD env vars.

    They were removed from the stac-fastapi ApiSettings in stac-fastapi 7.0.0, so we define them here
    with the same names and default values.
    """

    # Bind to all interfaces for container networking; override via APP_HOST.
    app_host: str = "0.0.0.0"  # nosec B104
    app_port: int = 8000
    reload: bool = True

    model_config = SettingsConfigDict(env_file=".env", extra="ignore")

run()

Run app from command line using uvicorn if available.

Source code in docs/rs-server/services/catalog/rs_server_catalog/main.py
def run():
    """Run app from command line using uvicorn if available."""
    try:
        import uvicorn  # pylint: disable=import-outside-toplevel

        uvicorn.run(
            "rs_server_catalog.app:app",
            host=settings.app_host,
            port=settings.app_port,
            log_level="info",
            reload=settings.reload,
            reload_dirs=[dir.strip() for dir in os.getenv("RELOAD_DIRS", "").split(",") if dir],
            # NOTE: don't set workers= use the WEB_CONCURRENCY env var instead
            root_path=os.getenv("UVICORN_ROOT_PATH", ""),
        )
    except ImportError:
        raise RuntimeError("Uvicorn must be installed in order to use command")  # pylint: disable=raise-missing-from