Repository navigation
feat(termux-worker): idle-gated restart-worker / restart-supervisor (#2791 stage 2b) - #2929
Merged
Merged
Conversation
…2791 stage 2b) Adds `restart-worker --if-idle` and `restart-supervisor --if-idle` to scripts/a2a-termux-native-worker.sh. restart-worker SIGTERMs only the supervisor's dist/worker.js child so the supervise loop relaunches it with the tunnel kept up; restart-supervisor stops the supervisor and respawns it through the health check's --self-heal path. The idle gate keeps #2138's BUSY_MAX meaning on the worker's process tree (a descendant younger than A2A_NATIVE_WORKER_BUSY_MAX_SECONDS is a running handler; older ones are hung and do not block) and fails closed when the tree is unreadable. Busy exits 10 and signals nothing; there is no unconditional mode. A restart is ok only after a new worker child, a fresh "registered with" line, a settle window, and health sup_count=1 workers=1 tunnel=UP (else rc 30). Self-update keeps warning about a stale worker.js (its restart belongs to the deploy side). A stale supervise loop of its own checkout is restarted only with CCC_SELF_UPDATE_NATIVE_SUPERVISOR_RESTART=1 (default 0); busy defers to the next tick. Refs #2791 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngs (#2791) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jinon86
approved these changes
Nov 27, 2026
jinon86
left a comment
Contributor
There was a problem hiding this comment.
Approved after exact-head validation and fresh operator authorization using the relay-held jinon86 credential.
seoseo-ai
pushed a commit
that referenced
this pull request
Nov 27, 2026
scripts/a2a-termux-native-worker-deploy.sh replaces the per-rollout ad-hoc Termux worker rollout scripts (owner decision 2026-11-27: the deploy side owns the worker.js restart; the script lives in ccc-node). Dry-run by default (plan + idle gate). --apply: idle gate via `restart-worker --if-idle --dry-run`, backups of the worker root and the replaced node_modules packages, copy dist/ scripts/ handlers/, check the build revision, the artifact's own rollout guard and an optional --smoke-cmd, then `restart-worker --if-idle` (registered with + health sup_count=1 workers=1 tunnel=UP) and write .deploy-source-sha. Failures roll the root back exactly; busy never signals the worker. Unsafe tar members are refused. Stacked on #2929 (stage 2b). Refs #2791 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
#2791 2단계(2b)입니다. Termux 네이티브 워커에 유휴 게이트를 거친 재기동 도구를 추가합니다. 오너 결정(2026-11-27, 세 항목 모두 1번)을 따릅니다.
PR1 #2928(ctime 탐지)과는 다른 파일을 고칩니다. 이 PR은
origin/main기준입니다. 3단계 배포 스크립트 PR은 이 브랜치 위에 쌓습니다.변경
scripts/a2a-termux-native-worker.shrestart-worker --if-idle [--env-file P] [--dry-run]dist/worker.js자식에만 SIGTERM을 보냅니다. supervise 루프가 8초 뒤 설치본으로 다시 띄우고, 터널은 유지됩니다.restart-supervisor --if-idle [--env-file P] [--dry-run]stop한 뒤 health--self-heal경로로 다시 띄웁니다. cron과 같은 경로입니다.BUSY_MAX의미를 cgroup 대신 워커 pid의 프로세스 트리에 적용합니다.A2A_NATIVE_WORKER_BUSY_MAX_SECONDS(기본값은CCC_SELF_UPDATE_BUSY_MAX_SECONDS, 없으면 1800)보다 젊은 프로세스가 있으면 busy입니다.hung=N으로 보고만 하고 kill하지 않습니다.CLOCK_BOOTTIME으로 잽니다. 트리를 읽지 못하면 fail-closed(rc 11)입니다.--if-idle없이 부르면 rc 2이며, 무조건 재기동하는 모드는 없습니다.result=ok입니다. 하나라도 어긋나면 rc 30입니다.registered with줄이 있음--json결과가sup_count=1 workers=1 tunnel=UP rc=0--env-file을 생략하면 실행 중인 supervisor의 argv에서 가져옵니다.scripts/ccc-self-update.sh(step 5c)native-worker-stale … action=none으로 경고만 남깁니다.CCC_SELF_UPDATE_NATIVE_SUPERVISOR_RESTART=1(opt-in)인 노드에서만 동작합니다.action=restart-supervisor로 남고restart-supervisor --if-idle을 호출합니다.native-supervisor-restart result=<ok|deferred-busy|deferred-unknown|failed> rc=…로 로그에만 남깁니다.…_RESTART_TIMEOUT(300초)입니다.worker.js는 opt-in이어도action=none입니다(배포 쪽 책임).action=none입니다.docs:
docs/a2a-claude-worker.md,docs/self-update.md. changelog:changelog.d/2791-native-worker-idle-restart.md검증 (로컬, jingun)
scripts/a2a-termux-native-worker-restart.test.sh(신규): PASS=28 FAIL=0/proc트리에서 유휴 게이트를 확인했습니다: 자식 없음 → idle, 젊은 자식 → busy, BUSY_MAX 초과 자식 → hung, 그 아래 젊은 손자 → busy, 무관한 프로세스는 무시, stat을 못 읽으면 → 11.scripts/ccc-self-update.test.sh: PASS=499 FAIL=0 (+6)a2a-termux-native-worker-health.test.sh53/0,a2a-termux-native-worker.test.sh57/0shellcheck -S warning(변경 파일 4개) cleanCCC_HARNESS_PHASE=static validate-harness.shPASScanon-node-name-scan.sh --repo-wideok(baseline 일치)changelog_fragments.py checkok범위 밖 / 게이트
Refs #2791
🤖 Generated with Claude Code