feat: add worker loop and production Dockerfiles

This commit is contained in:
Jonathan
2026-07-10 17:16:24 +02:00
parent d441d0561f
commit 3e44de093e
7 changed files with 67 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import time
from lyra_worker.claim import claim_next
from lyra_worker.db import connect
from lyra_worker.pipeline import run_pipeline
IDLE_SLEEP = 2.0
STAGE_DELAY = 1.0 # visible progress in the UI
def run_forever() -> None:
conn = connect()
print("worker: waiting for jobs", flush=True)
try:
while True:
job_id = claim_next(conn)
if job_id is None:
time.sleep(IDLE_SLEEP)
continue
print(f"worker: claimed job {job_id}", flush=True)
run_pipeline(conn, job_id, stage_delay=STAGE_DELAY)
print(f"worker: imported job {job_id}", flush=True)
finally:
conn.close()
if __name__ == "__main__":
run_forever()