fix(startup): move BQ table init to lifespan event — fixes Cloud Run startup probe timeout

This commit is contained in:
Chris Christiansen 2026-06-23 11:01:24 +00:00
parent ee50f8318e
commit 2950542c29
2 changed files with 2 additions and 2 deletions

View File

@ -52,8 +52,6 @@ except ImportError as _e:
return flash_model if mode != "heavy" else pro_model
class TokenBudgetExceeded(Exception): pass
create_bq_table_if_not_exists()
_OPAX_MCP_URL = os.environ.get("MCP_SERVER_URL", "https://opax-mcp-zjbqp3prqq-uc.a.run.app")
_MCP_SECRET = os.environ.get("MCP_SECRET", "")

View File

@ -22,6 +22,7 @@ try:
from google.genai.types import Content, Part
from agent import root_agent
from agents.recommendations_engine import get_recommendations
from token_logger import create_bq_table_if_not_exists
except ImportError as e:
logger.error(f"Failed to import ADK dependencies: {e}")
raise
@ -41,6 +42,7 @@ _budget_store: dict = {}
@asynccontextmanager
async def lifespan(app: FastAPI):
logger.info(f"OSVauco agent '{APP_NAME}' starting up")
create_bq_table_if_not_exists()
logger.info(f"Static dir: {STATIC_DIR} (exists={STATIC_DIR.exists()})")
yield
logger.info(f"OSVauco agent '{APP_NAME}' shutting down")