Files
ai-rpg/backend/app/workers/main.py
Mikan 5a78def096 fix
2026-06-19 16:31:45 +03:00

42 lines
1.2 KiB
Python

"""Worker entrypoint.
Historically this ran a trigger-polling loop. Triggers now fire in-process
inside the orchestrator when in-game time changes (see app.core.triggers),
so the worker has nothing to do at the moment. We keep the container running
as a placeholder for future background jobs (RAG re-indexer, summary
compactor, etc.).
If you add a background job, register it in `asyncio.gather(...)` below.
"""
from __future__ import annotations
import asyncio
from app.db_wait import wait_for_db_or_exit
from app.logging_setup import get_logger, setup_logging
log = get_logger("worker")
async def main():
setup_logging()
log.info("worker_starting")
# Make sure the DB is reachable and tables exist before doing anything.
# (Future background jobs may need this.)
await wait_for_db_or_exit(max_retries=60, delay=2.0)
log.info("worker_ready_no_jobs_registered")
# Nothing to do for now — sleep forever. Future background jobs go here:
# await asyncio.gather(
# some_future_loop(),
# another_future_loop(),
# )
while True:
await asyncio.sleep(3600)
if __name__ == "__main__":
asyncio.run(main())