2026-06-19 16:31:45 +03:00
|
|
|
"""Worker entrypoint.
|
2026-06-19 11:30:38 +03:00
|
|
|
|
2026-06-19 16:31:45 +03:00
|
|
|
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.
|
2026-06-19 11:30:38 +03:00
|
|
|
"""
|
2026-06-19 11:28:04 +03:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
|
2026-06-19 11:30:38 +03:00
|
|
|
from app.db_wait import wait_for_db_or_exit
|
2026-06-19 11:28:04 +03:00
|
|
|
from app.logging_setup import get_logger, setup_logging
|
|
|
|
|
|
|
|
|
|
log = get_logger("worker")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
|
setup_logging()
|
|
|
|
|
log.info("worker_starting")
|
2026-06-19 11:30:38 +03:00
|
|
|
|
2026-06-19 16:31:45 +03:00
|
|
|
# Make sure the DB is reachable and tables exist before doing anything.
|
|
|
|
|
# (Future background jobs may need this.)
|
2026-06-19 11:30:38 +03:00
|
|
|
await wait_for_db_or_exit(max_retries=60, delay=2.0)
|
|
|
|
|
|
2026-06-19 16:31:45 +03:00
|
|
|
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)
|
2026-06-19 11:28:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
asyncio.run(main())
|