Skip to content

Commit 9189bc6

Browse files
committed
feat: add runner log capture and debug endpoint
- Drop exec from run.sh so tee can capture output to /tmp/runner.log - Add POST /debug-runner-log endpoint to read logs from running sandboxes by job_id, enabling external debugging while sandbox is alive
1 parent 4620694 commit 9189bc6

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

app.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ async def github_webhook(request: Request):
747747
" && cd /actions-runner"
748748
" && export RUNNER_ALLOW_RUNASROOT=1"
749749
" && export DOCKER_BUILDKIT=1"
750-
" && exec ./run.sh --jitconfig $GHA_JIT_CONFIG"
750+
" && ./run.sh --jitconfig $GHA_JIT_CONFIG 2>&1 | tee /tmp/runner.log"
751751
)
752752

753753
sandbox_kwargs = dict(
@@ -835,3 +835,27 @@ async def github_webhook(request: Request):
835835
"limit": MAX_CONCURRENT_PER_REPO,
836836
},
837837
)
838+
839+
840+
@app.function(image=runner_image, secrets=[github_secret])
841+
@modal.fastapi_endpoint(method="POST")
842+
async def debug_runner_log(request: Request):
843+
"""Read /tmp/runner.log from a running sandbox by job_id."""
844+
try:
845+
body = await request.json()
846+
job_id = body.get("job_id")
847+
if not job_id:
848+
raise HTTPException(status_code=400, detail="Missing job_id")
849+
850+
for sb in modal.Sandbox.list(app_id=app.app_id, tags={"job_id": str(job_id)}):
851+
try:
852+
log = sb.filesystem.read_text("/tmp/runner.log")
853+
return {"job_id": job_id, "log": log}
854+
except Exception:
855+
continue
856+
857+
return {"job_id": job_id, "log": "Sandbox not found or log not available"}
858+
except HTTPException:
859+
raise
860+
except Exception as e:
861+
raise HTTPException(status_code=500, detail=f"Error reading runner log: {e}")

0 commit comments

Comments
 (0)