Skip to content

fix(server): distinguish alive-but-busy from dead opencode process in health checks#248

Open
chriswritescode-dev wants to merge 1 commit into
mainfrom
forge/opencode-liveness-restart
Open

fix(server): distinguish alive-but-busy from dead opencode process in health checks#248
chriswritescode-dev wants to merge 1 commit into
mainfrom
forge/opencode-liveness-restart

Conversation

@chriswritescode-dev
Copy link
Copy Markdown
Owner

Introduce the concept of "alive but not ready" for the OpenCode server process. If the process is alive but not answering health probes (e.g., still starting, busy), treat it as degraded rather than killing and restarting it. Add unexpected exit detection so the supervisor can recover immediately on crashes.

  • Add isProcessAlive() to check process existence via process.kill(pid, 0)
  • Add onUnexpectedExit() listener system for crash detection
  • Skip killing a busy-but-alive server during startup health check timeout
  • Add ready field to OpenCodeLifecycleStatus (separate from healthy)
  • markBusy() sets healthy=true, ready=false to prevent restart loops
  • Supervisor handles unexpected exits and triggers recovery immediately
  • Report opencode: "busy" in health endpoint when alive but not ready
  • Configurable HEALTH_PROBE_TIMEOUT_MS (default 10s) for health check probes
  • Test coverage for all new behavior

Files

  • backend/src/routes/health.ts
  • backend/src/services/opencode-single-server.ts
  • backend/src/services/opencode-supervisor.ts
  • backend/test/routes/health.test.ts
  • backend/test/services/opencode-single-server.test.ts
  • backend/test/services/opencode-supervisor.test.ts
  • shared/src/config/defaults.ts
  • shared/src/config/env.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant