Bug bash fixes: hash routing + back button, hub-only pages reset on machine switch, exited terminals reap after 10 min, self-update refuses while busy unless forced, touch-sized controls, power confirm by machine name, down interfaces collapsed and empty modules hidden, load label, offline backoff, cron log newest first, procs empty message, timer timestamp parsing
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
27f9665606
commit
f093b322ee
+22
-3
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"log"
|
||||
@@ -328,6 +329,20 @@ func (s *Server) removeNode(w http.ResponseWriter, r *http.Request) {
|
||||
// selfUpdate receives a new binary from a hub, checks it runs, installs it over the
|
||||
// current executable (keeping a .prev copy) and restarts the service.
|
||||
func (s *Server) selfUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Query().Get("force") != "1" {
|
||||
if t, ok := s.tasks.RunningOf("updates"); ok {
|
||||
jsonErr(w, 409, "busy: a package task is running ("+t.Title+"); retry with force to interrupt it")
|
||||
return
|
||||
}
|
||||
attached := 0
|
||||
for _, t := range s.mgr.List() {
|
||||
attached += t.Clients
|
||||
}
|
||||
if attached > 0 {
|
||||
jsonErr(w, 409, fmt.Sprintf("busy: %d terminal client(s) attached; retry with force to drop them", attached))
|
||||
return
|
||||
}
|
||||
}
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
jsonErr(w, 500, err.Error())
|
||||
@@ -396,10 +411,14 @@ func copyFile(src, dst string) error {
|
||||
|
||||
func (s *Server) updateMachine(w http.ResponseWriter, r *http.Request) {
|
||||
exe, _ := os.Executable()
|
||||
res := s.nodes.Push(r.Context(), r.PathValue("name"), exe, runtime.GOARCH)
|
||||
res := s.nodes.Push(r.Context(), r.PathValue("name"), exe, runtime.GOARCH, r.URL.Query().Get("force") == "1")
|
||||
log.Printf("machines: update %s -> ok=%v %s %s (from %s)", res.Name, res.OK, res.Version, res.Error, clientIP(r))
|
||||
if !res.OK {
|
||||
jsonErr(w, 400, res.Error)
|
||||
code := 400
|
||||
if strings.HasPrefix(res.Error, "busy:") {
|
||||
code = 409
|
||||
}
|
||||
jsonErr(w, code, res.Error)
|
||||
return
|
||||
}
|
||||
jsonOK(w, 200, res)
|
||||
@@ -407,7 +426,7 @@ func (s *Server) updateMachine(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) updateAllMachines(w http.ResponseWriter, r *http.Request) {
|
||||
exe, _ := os.Executable()
|
||||
res := s.nodes.PushAll(r.Context(), exe, runtime.GOARCH)
|
||||
res := s.nodes.PushAll(r.Context(), exe, runtime.GOARCH, r.URL.Query().Get("force") == "1")
|
||||
for _, x := range res {
|
||||
log.Printf("machines: update %s -> ok=%v %s %s (from %s)", x.Name, x.OK, x.Version, x.Error, clientIP(r))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user