New scripts
Deploy / deploy (push) Successful in 8s

This commit is contained in:
2026-08-29 14:41:40 +05:00
parent 3f400694d8
commit e4f58e820f
4 changed files with 38 additions and 3 deletions
+17 -1
View File
@@ -56,6 +56,21 @@ func loadConfig(path string) (*Config, error) {
if err := dec.Decode(&cfg); err != nil {
return nil, fmt.Errorf("parse %s: %w", path, err)
}
seen := map[string]bool{} // item names are global keys (monVals, RunScript)
for _, l := range cfg.Links {
if seen[l.Name] {
return nil, fmt.Errorf("duplicate name %q", l.Name)
}
seen[l.Name] = true
}
for _, list := range [][]Item{cfg.Monitor, cfg.Exec} {
for _, it := range list {
if seen[it.Name] {
return nil, fmt.Errorf("duplicate name %q", it.Name)
}
seen[it.Name] = true
}
}
for _, it := range cfg.Monitor {
if it.Refresh <= 0 {
return nil, fmt.Errorf("monitor %q: refresh must be > 0", it.Name)
@@ -109,7 +124,8 @@ func (s *server) startMonitors() {
log.Printf("monitor %s: %v", sc.Name, err)
v = "error: " + err.Error()
} else {
log.Printf("monitor %s -> %s", sc.Name, strings.TrimSpace(v))
v = strings.TrimSpace(v)
log.Printf("monitor %s -> %s", sc.Name, v)
}
s.monVals.Store(sc.Name, v)
time.Sleep(time.Duration(sc.Refresh) * time.Second)