Skip to content

feat: add gateway watchdog command#134

Merged
QiuYi111 merged 1 commit into
mainfrom
feat/gateway-watchdog
Apr 18, 2026
Merged

feat: add gateway watchdog command#134
QiuYi111 merged 1 commit into
mainfrom
feat/gateway-watchdog

Conversation

@QiuYi111
Copy link
Copy Markdown
Owner

Summary

Add linear watchdog CLI subcommand for standalone gateway health monitoring.

Three independent checks

Check What it verifies
network Can we reach api.linear.app at all? (Distinguishes broken network from expired token)
token Does the current token in ~/.linear-gateway/token.json authenticate successfully? (viewer query)
gateway Is the gateway HTTP server responding on /health?

Auto-repair

With --fix, automatically restarts the gateway via pm2 restart linear-gateway when the health endpoint is unreachable.

Usage

# One-shot check (exit 0 = healthy, 1 = unhealthy)
linear watchdog

# With auto-repair
linear watchdog --fix

# Custom port + JSON output (for cron logging)
linear watchdog --port 9091 --json

Cron integration

*/3 * * * * linear watchdog --fix --json >> /var/log/linear-watchdog.log 2>&1

Implementation

  • src/standalone/watchdog.ts — Core logic, reuses FileTokenStore and resolveLinearToken
  • src/standalone/cli.ts — CLI subcommand with --port, --fix, --json, --token-store flags
  • src/__test__/watchdog.test.ts — 8 unit tests covering all failure modes and repair

No new runtime dependencies. Follows existing project conventions (ESM, strict TS, Biome, Vitest).

Health-checks the standalone gateway with three independent checks:
1. Network connectivity (can we reach Linear API?)
2. Token validity (can we authenticate with current token?)
3. Gateway process (is the HTTP server responding?)

Supports --fix flag for auto-repair (pm2 restart) and --json for
structured output. Designed for cron/systemd timer integration.

Usage: linear watchdog [--port 8091] [--fix] [--json]
@QiuYi111 QiuYi111 merged commit 1637879 into main Apr 18, 2026
1 of 3 checks passed
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