diff --git a/deploy/install_prefill_worker_launchd.sh b/deploy/install_prefill_worker_launchd.sh index 7a7b4c38..f0bf1bcd 100755 --- a/deploy/install_prefill_worker_launchd.sh +++ b/deploy/install_prefill_worker_launchd.sh @@ -88,7 +88,24 @@ cat > "$PLIST" </dev/null || true -launchctl bootstrap "gui/$(id -u)" "$PLIST" +DOMAIN="gui/$(id -u)" +launchctl bootout "$DOMAIN/$LABEL" 2>/dev/null || true +for _ in {1..20}; do + if ! launchctl print "$DOMAIN/$LABEL" >/dev/null 2>&1; then + break + fi + sleep 0.25 +done +for attempt in 1 2 3; do + if launchctl bootstrap "$DOMAIN" "$PLIST"; then + break + fi + if [[ "$attempt" -eq 3 ]]; then + echo "failed to bootstrap $LABEL after $attempt attempts" >&2 + exit 1 + fi + sleep 2 +done +launchctl kickstart -k "$DOMAIN/$LABEL" echo "installed $LABEL -> $PLIST" diff --git a/tests/inference_engine/bridge/test_prefill_worker_launchd.py b/tests/inference_engine/bridge/test_prefill_worker_launchd.py index e31390ad..542f54fa 100644 --- a/tests/inference_engine/bridge/test_prefill_worker_launchd.py +++ b/tests/inference_engine/bridge/test_prefill_worker_launchd.py @@ -23,6 +23,9 @@ def test_worker_installer_emits_full_cache_compatibility_contract(): assert 'PEER="${KAKEYA_WORKER_PEER:-}"' in source assert "--peer" in source assert 'chmod 644 "$PLIST"' in source + assert 'launchctl print "$DOMAIN/$LABEL"' in source + assert "for attempt in 1 2 3" in source + assert 'launchctl kickstart -k "$DOMAIN/$LABEL"' in source def test_head_runtime_discovers_and_uses_worker_cache_port():