"""cPanel Passenger entry point for the FastAPI application.

Passenger serves WSGI applications, while FastAPI uses ASGI.  a2wsgi provides
the small compatibility layer required on WHC shared hosting.
"""

import os
import sys
from pathlib import Path

APP_ROOT = Path(__file__).resolve().parent
SOURCE_ROOT = APP_ROOT / "src"
if str(SOURCE_ROOT) not in sys.path:
    sys.path.insert(0, str(SOURCE_ROOT))

# Passenger does not run FastAPI's ASGI lifespan protocol, so initialize the
# database and migrations explicitly when the application process starts.
from lic_webapp.database import init_db  # noqa: E402

init_db()

from a2wsgi import ASGIMiddleware  # noqa: E402
from lic_webapp.main import app  # noqa: E402

application = ASGIMiddleware(app)
