lerko f023e38fdc refactor(monitor): encapsulate engine state, add graceful shutdown and tests
Replace all monitor package-level mutable state with Engine struct.
All state (liveState, logStore, histories, tokenIndex, HTTP clients)
is now encapsulated in Engine, created via NewEngine(store).

Key changes:
- Engine struct holds all monitor state with proper mutex protection
- Engine.Start(ctx) and monitorRoutine respect context cancellation
  for graceful shutdown — no more leaked goroutines
- cluster.runFollowerLoop also respects context for clean exit
- Token index (map[string]int) for O(1) push heartbeat lookup,
  replacing O(n) linear scan through LiveState
- UpdateSiteConfig preserves 8 runtime fields instead of copying
  17 config fields individually
- triggerAlert goroutines get 30s timeout context
- All consumers (TUI, server, cluster, main) receive *Engine via
  constructor/parameter — no package-level state access
- main.go creates context.WithCancel, passes to engine and cluster

First test suite: 12 tests across store and alert packages
- Store: CRUD for sites/alerts/users, push token generation,
  import/export round-trip, check history persistence
- Alert: Discord/Slack/Webhook payload format, HTTP 4xx error
  propagation, Ntfy headers, unknown provider returns nil
2026-05-15 08:21:17 -04:00

Go-Upkeep

Go Version License Docker

Go-Upkeep is a self-hosted infrastructure monitor with a retro-futuristic TUI accessible via SSH. It supports High Availability, Push Monitoring, and Alerting.


🚀 Key Features

  • SSH Dashboard: Zero-install client. Manage monitors via ssh -p 23234 your-server.
  • Protocols:
    • HTTP/S: Active polling with SSL certificate expiration tracking.
    • PUSH: Heartbeat endpoints for cron jobs/backup scripts.
  • High Availability: Leader/Follower clustering with automatic failover.
  • Alerting: Native support for Discord, Slack, Email (SMTP), and Webhooks.
  • Backends: SQLite (default) or PostgreSQL (production).

🛠️ Quick Start (Local Dev)

Option A: Native Go (Fastest)

go mod tidy
go run cmd/goupkeep/main.go
# Connect: ssh -p 23234 localhost

Option B: Docker Compose (Full Stack)

docker compose -f docker-compose.dev.yml up --build

📦 Production Deployment

For critical infrastructure, we recommend Docker Compose.

1. The Compose File

Create docker-compose.yml:

services:
  monitor:
    image: rdgames1000/go-upkeep:latest
    container_name: go-upkeep
    restart: unless-stopped
    stdin_open: true # Required for initial setup console
    tty: true
    ports:
      - "23234:23234" # SSH
      - "8080:8080"   # HTTP (Status Page & Push)
    volumes:
      - ./data:/data
      - ./ssh_keys:/app/.ssh
    environment:
      - UPKEEP_DB_TYPE=sqlite
      - UPKEEP_DB_DSN=/data/upkeep.db
      - UPKEEP_STATUS_ENABLED=true
      - UPKEEP_CLUSTER_SECRET=ChangeMeToSomethingSecure

2. Initial Setup (Identity Management)

Important: V2 stores SSH keys in the database. You must create the first user manually via the console.

  1. Start the stack: docker compose up -d
  2. Attach to the container: docker attach go-upkeep
  3. Inside the TUI:
    • Press [Tab] to select the Users tab.
    • Press [n] to create a user.
    • Enter your username and paste your public key (cat ~/.ssh/id_ed25519.pub).
    • Press [Enter] to save.
  4. Detach: Press Ctrl+P then Ctrl+Q.

3. Usage

Connect using your standard SSH client:

ssh -p 23234 your-server-ip

For advanced setups (Postgres, Clustering, Migration), please consult the Official Documentation.

📄 License

MIT License.

S
Description
Live uptime monitoring dashboard for your terminal. SSH-accessible. HTTP, ping, TCP, DNS, push checks with alerts, clustering, and Prometheus metrics.
Readme MIT 2.2 MiB
2026.05.6 Latest
2026-05-30 23:34:56 +00:00
Languages
Go 99.7%
Dockerfile 0.3%