From 031f6b85e90eb9540b43f69996a302d86c031676 Mon Sep 17 00:00:00 2001 From: URP2026 Date: Wed, 29 Jul 2026 18:45:25 +0900 Subject: [PATCH] =?UTF-8?q?act=5Frunner=20=ED=8F=B4=EB=A7=81=20=EC=A0=95?= =?UTF-8?q?=EC=A7=80=20=EC=9B=8C=EC=B9=98=EB=8F=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 러너가 작업 하나를 끝낸 뒤 폴링을 멈추는 문제가 있다. 프로세스는 살아 있고 Gitea로의 TCP 연결도 ESTABLISHED 인데 응답 없이 물려 있으며 CPU 사용량이 완전히 정지한다. nginx 경유 제거(직결 재등록)와 0.2.11->0.2.13 업그레이드로도 재현되어 근본 원인을 잡지 못했다. arko-runner-watchdog.timer 가 1분마다 "90초 넘게 대기 중인 작업이 있는데 실행 중인 작업은 없는" 상태를 확인해 러너를 재기동한다. 실행 중인 작업이 있으면 건드리지 않으므로 배포 도중 끊길 위험은 없다. 검증: 대기 중이던 run 67을 워치독이 감지해 재기동했고 배포가 정상 완료됐다. --- deploy/README.md | 25 ++++++++++++---- deploy/dev/arko-runner-watchdog.service | 11 +++++++ deploy/dev/arko-runner-watchdog.sh | 38 +++++++++++++++++++++++++ deploy/dev/arko-runner-watchdog.timer | 14 +++++++++ 4 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 deploy/dev/arko-runner-watchdog.service create mode 100644 deploy/dev/arko-runner-watchdog.sh create mode 100644 deploy/dev/arko-runner-watchdog.timer diff --git a/deploy/README.md b/deploy/README.md index efb2c7f..d4e22b1 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -99,11 +99,26 @@ tail -f /var/log/nginx/csv.wise.ai.kr.error.log ## 알려진 이슈 -**runner가 작업을 가져오지 않는 경우** — act_runner를 nginx(`https://git.zioinfo.co.kr`)를 -경유해 등록하면 `declare successfully` 까지는 가는데 작업을 집어가지 않고, 재기동해야만 -대기 중이던 작업을 처리했다. long-poll이 nginx의 `proxy_buffering`(기본 on)에 물리는 것으로 -보인다. `deploy/dev/06-runner-reregister.sh` 로 Gitea에 직접(`127.0.0.1:9003`) 붙여 해결했다. -같은 증상이 재발하면 이 스크립트를 다시 실행할 것. +**act_runner 폴링 정지 (미해결 — 워치독으로 우회 중)** + +act_runner가 작업 하나를 끝낸 뒤 폴링을 멈춘다. 프로세스는 살아 있고 Gitea로의 TCP 연결도 +`ESTABLISHED` 인데 응답 없이 물려 있으며, CPU 사용량이 완전히 정지한다(20초 관찰 시 +utime/stime 변화 0). 재기동하면 밀린 작업을 즉시 집어간다. + +시도한 것과 결과: + +| 조치 | 결과 | +|---|---| +| nginx 경유 제거 → Gitea 직결(`127.0.0.1:9003`) 재등록 (`06-runner-reregister.sh`) | 재현 | +| act_runner 0.2.11 → 0.2.13 업그레이드 (`07-runner-upgrade.sh`) | 재현 | + +근본 원인을 잡지 못해 **워치독으로 보완**했다. `arko-runner-watchdog.timer`가 1분마다 +"대기 90초 넘긴 작업이 있는데 실행 중인 작업은 없는" 상태를 확인해 러너를 재기동한다. +실행 중인 작업이 있으면 절대 건드리지 않으므로 배포 도중 끊길 일은 없다. +동작 기록은 `/opt/arko-dev/logs/watchdog.log`. + +즉 **배포는 자동으로 완료되지만, 러너가 멈췄다가 최대 1분 뒤 워치독에 의해 살아나 처리되는 +경우가 있다.** 배포가 1~2분 늦어지는 것으로 보일 수 있다. **Gitea 1.22는 `workflow_dispatch`를 지원하지 않는다** — 넣으면 워크플로가 Actions 목록에 아예 뜨지 않는다. 수동 재배포는 `git commit --allow-empty` 후 push 로 한다. diff --git a/deploy/dev/arko-runner-watchdog.service b/deploy/dev/arko-runner-watchdog.service new file mode 100644 index 0000000..057f722 --- /dev/null +++ b/deploy/dev/arko-runner-watchdog.service @@ -0,0 +1,11 @@ +# arko-runner-watchdog.timer 가 호출하는 1회성 작업 +# 설치: /etc/systemd/system/arko-runner-watchdog.service +[Unit] +Description=arko act_runner 폴링 정지 감시 (1회 점검) +After=arko-dev-runner.service + +[Service] +Type=oneshot +ExecStart=/opt/arko-dev/bin/arko-runner-watchdog.sh +User=root +Group=root diff --git a/deploy/dev/arko-runner-watchdog.sh b/deploy/dev/arko-runner-watchdog.sh new file mode 100644 index 0000000..d43645c --- /dev/null +++ b/deploy/dev/arko-runner-watchdog.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# act_runner 폴링 정지 감시 — 밀린 작업이 있는데 러너가 놀고 있으면 재기동한다. +# +# 설치 위치: /opt/arko-dev/bin/arko-runner-watchdog.sh (systemd timer가 1분마다 호출) +# +# 왜 필요한가: +# act_runner(0.2.11, 0.2.13 모두)가 작업 하나를 끝낸 뒤 폴링을 멈춘다. +# 프로세스는 살아 있고 Gitea로의 TCP 연결도 ESTABLISHED 인데 응답 없이 물려 있으며, +# CPU 사용량이 완전히 멈춘다(20초 관찰 시 utime/stime 변화 0). 재기동하면 밀린 작업을 +# 즉시 집어간다. nginx 경유를 걷어내고 Gitea에 직결한 뒤에도 재현되어 러너 결함으로 판단했다. +# +# 안전장치: 실행 중인 작업이 있으면 절대 재기동하지 않는다(배포 도중 끊기면 ROOT가 반쪽이 된다). +set -uo pipefail + +REPO_ID=55 # somang4819/arko_renual +SERVICE=arko-dev-runner +STALE_SEC=90 # 이 시간 이상 대기 중인 작업이 있으면 폴링이 멈춘 것으로 본다 +LOG=/opt/arko-dev/logs/watchdog.log + +mkdir -p "$(dirname "$LOG")" +log() { echo "[$(date +'%F %T')] $*" >> "$LOG"; } + +PSQL() { su - postgres -c "psql -d gitea_db -A -t -c \"$1\"" 2>/dev/null | tr -d ' \r'; } + +# 1) 실행 중인 작업이 있으면 손대지 않는다 (status 6 = Running) +RUNNING=$(PSQL "select count(*) from action_run_job where repo_id=$REPO_ID and status=6;") +[ "${RUNNING:-0}" = "0" ] || exit 0 + +# 2) 오래 대기 중인 작업 확인 (status 5 = Waiting) +WAITING=$(PSQL "select count(*) from action_run_job j join action_run r on r.id=j.run_id + where j.repo_id=$REPO_ID and j.status=5 and r.created < extract(epoch from now())-$STALE_SEC;") +[ "${WAITING:-0}" -gt 0 ] 2>/dev/null || exit 0 + +# 3) 러너가 살아 있는데도 안 가져간 것이므로 재기동 +log "대기 작업 ${WAITING}건 감지 — $SERVICE 재기동" +systemctl restart "$SERVICE" +sleep 10 +log "재기동 완료: $(systemctl is-active $SERVICE)" diff --git a/deploy/dev/arko-runner-watchdog.timer b/deploy/dev/arko-runner-watchdog.timer new file mode 100644 index 0000000..0d88f5a --- /dev/null +++ b/deploy/dev/arko-runner-watchdog.timer @@ -0,0 +1,14 @@ +# act_runner 폴링 정지 감시 타이머 +# 설치: /etc/systemd/system/arko-runner-watchdog.timer (+ .service) +# systemctl enable --now arko-runner-watchdog.timer +[Unit] +Description=arko act_runner 폴링 정지 감시 (1분 주기) + +[Timer] +OnBootSec=2min +OnUnitActiveSec=1min +AccuracySec=15s +Unit=arko-runner-watchdog.service + +[Install] +WantedBy=timers.target