a91a1132c9
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 2m10s
Introduce a standalone scheduled info-engine worker with SQLite persistence and expose read-only dashboard APIs/UI so curated intelligence items can be collected and viewed with minimal architecture changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1010 B
Python
38 lines
1010 B
Python
import asyncio
|
|
import logging
|
|
import os
|
|
|
|
from collector import collect_sources
|
|
from db import init_db, upsert_items
|
|
from processor import process_items
|
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s")
|
|
log = logging.getLogger(__name__)
|
|
|
|
COLLECT_INTERVAL_SECONDS = int(os.environ.get("INFO_ENGINE_INTERVAL_SECONDS", "900"))
|
|
|
|
|
|
async def run_once() -> int:
|
|
raw_items = await collect_sources()
|
|
processed = process_items(raw_items)
|
|
inserted = await upsert_items(processed)
|
|
return inserted
|
|
|
|
|
|
async def main():
|
|
await init_db()
|
|
log.info("Info engine started (interval=%ss)", COLLECT_INTERVAL_SECONDS)
|
|
|
|
while True:
|
|
try:
|
|
inserted = await run_once()
|
|
log.info("Info engine cycle complete (inserted=%d)", inserted)
|
|
except Exception as exc:
|
|
log.error("Info engine cycle failed: %s", exc)
|
|
|
|
await asyncio.sleep(COLLECT_INTERVAL_SECONDS)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|