Files
worker/internal/webapp/handlers_status.go
Gleb Tv 2c7a0236da feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
2026-07-13 17:55:14 +03:00

39 строки
1.2 KiB
Go

package webapp
import (
"net/http"
"time"
)
// handleStatus renders the host metrics snapshot. Phase 1 reads
// only /proc and statfs; the lsblk / smartctl / sensors
// integrations are deferred to the worker webapp expansion tracked
// in docs/distributed/worker-web-app.md §6.7 (out of band; not
// shipped in this repo). The current Snapshot struct accommodates
// the extra sections if/when those are wired in.
//
// TODO(worker-web-app §6.7): surface lsblk / smartctl / sensors /
// docker info on this page once the worker process is allowed to
// invoke those CLI tools. The cli tools are not bundled with the
// worker binary; install them separately on the host if needed.
func (s *Server) handleStatus(w http.ResponseWriter, r *http.Request) {
writeNoStore(w)
sess, _ := sessionFromContext(r.Context())
snap, snapAt := s.metrics.Last()
data := statusPageData{
basePageData: s.newBasePage(r, "Server status", sess),
Snapshot: snap,
SnapshotAt: snapAt,
}
if err := s.templates.Execute(w, "status.html", data); err != nil {
s.deps.Logger.Printf("render status: %v", err)
http.Error(w, "template error", http.StatusInternalServerError)
}
}
type statusPageData struct {
basePageData
Snapshot Snapshot
SnapshotAt time.Time
}