v0.1.0

Monitoring Cycle

This page explains when go-web-monitor checks sites, how it runs checks concurrently, and how each round's results reach the config file and the screen.

Triggers

Trigger Source Behavior
Startup UI.start() (internal/service/ui.go:96) Runs one Monitor.Update() round as soon as the interface starts
Every minute time.NewTicker(1 * time.Minute) Runs Update() at a fixed interval; the interval is not configurable
refresh command handleCommand Runs one Update() round in a background goroutine right away
add <url> command Monitor.Add() Checks only the newly added site

Exiting (quit or Ctrl+C) closes the quit channel, which stops the schedule loop.

Flow of One Round

sequenceDiagram
    participant U as UI
    participant M as Monitor
    participant W as Target site
    participant F as .webMonitor.json
    U->>M: Update()
    par One goroutine per site
        M->>W: Check(url)
        W-->>M: model.Website
        M->>M: Update failure count, alert if needed
    end
    M->>F: Save()
    U->>U: QueueUpdateDraw(updateUI)
  1. Update() (internal/service/monitor.go:159) starts one goroutine per URL in the watch list and waits for all of them with a sync.WaitGroup.
  2. Each goroutine calls Check() to get the status code, duration, and SSL days remaining (see HTTP Probing and SSL Expiry).
  3. The result updates the site's failure count, and the 5th consecutive offline check sends an alert (see Alert Rules).
  4. When every goroutine finishes, Save() overwrites .webMonitor.json with the full status and SMTP config.
  5. The interface redraws the table and System panel through QueueUpdateDraw.

Duration Bound

A round takes as long as its slowest site. The worst case for one site is HEAD and GET each hitting the 10-second timeout, plus the SSL certificate connection; sites run in parallel, so these times do not add up across sites.

When the Config File Is Written

When Content written
End of each Update() round Every site's status plus the SMTP config
After a successful add / del Same
After any smtp <key> <value> command Same

Writes overwrite the whole file (util.Save), so manual edits made while the program runs are lost.

中文