問題: Runner 並行執行時 "file already exists" 導致 CD 失敗 解決方案: 1. CD Workflow: 刪除整個 _diag/pages 目錄再重建 (非 rm -rf /*) 2. Systemd Timer: 每 5 分鐘自動清理過期檔案 3. flock 鎖定: 防止清理程序競爭 新增檔案: - ops/runner/cleanup-runner-diag.sh - 清理腳本 - ops/runner/runner-diag-cleanup.service - Systemd service - ops/runner/runner-diag-cleanup.timer - 定時器 - ops/runner/deploy-runner-cleanup.sh - 部署腳本 - ops/runner/README.md - 文檔 部署指令: ssh wooo@192.168.0.110 bash awoooi/ops/runner/deploy-runner-cleanup.sh Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GitHub Actions Runner 穩定性修復
問題: _diag/pages 檔案衝突
Error: The file '/home/wooo/actions-runner-awoooi/_diag/pages/xxx.log' already exists.
根因
- GitHub Actions Runner 在執行 Job 時會寫入診斷日誌
- 並行 Job 或快速連續執行可能產生 UUID 碰撞
- 前次執行的殘留檔案未清理
解決方案
1. CD Workflow 修復 (即時生效)
每個 Job 開始前強制清理並重建 _diag/pages 目錄:
- name: "Clean Runner Diagnostics"
run: |
RUNNER_ROOT=$(dirname "$(dirname "$RUNNER_TEMP")")
rm -rf "$RUNNER_TEMP"/* "$RUNNER_ROOT/_diag/pages" .claude/worktrees 2>/dev/null || true
mkdir -p "$RUNNER_ROOT/_diag/pages" 2>/dev/null || true
關鍵: 刪除整個目錄再重建,而非 rm -rf _diag/pages/*
2. Systemd Timer (背景清理)
每 5 分鐘自動清理過期的診斷檔案:
# 部署
ssh wooo@192.168.0.110
cd /path/to/awoooi/ops/runner
bash deploy-runner-cleanup.sh
檔案說明
| 檔案 | 用途 |
|---|---|
cleanup-runner-diag.sh |
清理腳本 (安裝到 Runner 目錄) |
runner-diag-cleanup.service |
Systemd service 定義 |
runner-diag-cleanup.timer |
Systemd timer (每 5 分鐘) |
deploy-runner-cleanup.sh |
一鍵部署腳本 |
監控
# 查看 timer 狀態
sudo systemctl status runner-diag-cleanup.timer
# 查看清理日誌
journalctl -u runner-diag-cleanup.service -f
# 手動觸發清理
sudo systemctl start runner-diag-cleanup.service
相關文件
- Memory:
feedback_runner_zombie_process.md - ADR: 待建立 (如果問題持續)
版本: v1.0 | 建立: 2026-03-29 | 作者: Claude Code