mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-06 08:10:48 +00:00
Replace the broken keep-alive ping loop with a fundamentally better approach: the trigger server now streams the script's stdout/stderr back as the HTTP response body in chunks. The GH Action holds the curl connection open for the entire cycle duration (~90 min timeout). This works because Sprite keeps VMs alive while "actively servicing HTTP requests." A single long-lived streaming response satisfies this naturally — no synthetic pings needed. Key changes: trigger-server.ts: - /trigger now returns a streaming text/plain Response - stdout/stderr piped through ReadableStream with chunked output - 30s heartbeat lines injected during silent periods - Client disconnect handled gracefully (process keeps running) - X-Accel-Buffering: no header to prevent proxy buffering discovery.yml / refactor.yml: - curl -sSN --fail-with-body streams output in real-time - timeout-minutes: 90 to hold the connection for full cycles - Error responses (429/409/401) still print body and exit cleanly discovery.sh / refactor.sh: - Removed all keep-alive logic (start_keepalive/stop_keepalive) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
name: Trigger Refactor
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '*/5 * * * *'
|
|
issues:
|
|
types: [opened, reopened]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: refactor-sprite-trigger
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
trigger:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: Trigger and stream refactor cycle
|
|
env:
|
|
SPRITE_URL: ${{ secrets.REFACTOR_SPRITE_URL }}
|
|
TRIGGER_SECRET: ${{ secrets.REFACTOR_TRIGGER_SECRET }}
|
|
run: |
|
|
set +e
|
|
# --fail-with-body: exit 22 on HTTP errors but still print the body
|
|
# -N: no output buffering (stream chunks in real-time)
|
|
# --max-time: hard cap matching the Sprite's cycle timeout + grace
|
|
curl -sSN --fail-with-body --max-time 5400 -X POST \
|
|
"${SPRITE_URL}/trigger?reason=${{ github.event_name }}&issue=${{ github.event.issue.number || '' }}" \
|
|
-H "Authorization: Bearer ${TRIGGER_SECRET}"
|
|
CURL_EXIT=$?
|
|
set -e
|
|
|
|
if [ "$CURL_EXIT" -eq 0 ]; then
|
|
echo ""
|
|
echo "=== Cycle completed ==="
|
|
elif [ "$CURL_EXIT" -eq 22 ]; then
|
|
# HTTP error — body was already printed above (429 = already running, 409 = dedup, etc.)
|
|
echo ""
|
|
echo "=== Trigger returned HTTP error (see output above) ==="
|
|
else
|
|
echo ""
|
|
echo "=== curl failed (exit=$CURL_EXIT) ==="
|
|
exit 1
|
|
fi
|