fix(ops): harden backend startup and worker recovery

Install modular API, voice and embedding extras and use the supported single-process server entrypoint. Drain worker SIGTERM shutdown within the Compose grace period.

Add isolated HTTPS embedding fixtures, bounded intake execution and reproducible account, publication, restart, lease-recovery and shutdown acceptance. Eight operational scenarios passed with zero real-provider calls.
This commit is contained in:
11linear11
2026-10-09 17:44:04 -04:00
parent a73a496c54
commit 42f5b9e854
9 changed files with 760 additions and 5 deletions
+29
View File
@@ -0,0 +1,29 @@
"""SIGTERM drains the current fenced job, wakes idle polling and releases DB resources."""
from contextlib import nullcontext
import signal
from types import SimpleNamespace
import pytest
from app import worker
@pytest.mark.parametrize('processed', [False, True])
def test_sigterm_stops_new_claims_and_disposes_engine(settings, monkeypatch, processed):
calls=[]
previous=signal.getsignal(signal.SIGTERM)
engine=SimpleNamespace(connect=lambda: nullcontext(None), dispose=lambda: calls.append('dispose'))
monkeypatch.setattr(worker,'IngestionSettings',lambda: settings)
monkeypatch.setattr(worker,'create_database',lambda _: engine)
monkeypatch.setattr(worker,'check_compatibility',lambda *a,**kw: None)
monkeypatch.setattr(worker,'SqlWorkerRepository',lambda *a: None)
class Active:
def run_once(self, _):
calls.append('claim')
signal.getsignal(signal.SIGTERM)(signal.SIGTERM,None)
calls.append('finished')
return processed
monkeypatch.setattr(worker,'Worker',lambda *a: Active())
assert worker.main([])==0
assert calls==['claim','finished','dispose']
assert signal.getsignal(signal.SIGTERM)==previous