feat: enhance agent management with support for multiple instances and update UI accordingly

This commit is contained in:
2026-03-04 23:41:26 +00:00
parent bcbbd974e3
commit 1e5103eb70
7 changed files with 48 additions and 48 deletions
+10 -11
View File
@@ -74,14 +74,15 @@ func listCmd(mgr *process.Manager) *cobra.Command {
return nil
}
fmt.Printf("%-20s %-12s %-8s %s\n", "ID", "STATUS", "VERSION", "DESCRIPTION")
fmt.Println(strings.Repeat("─", 72))
fmt.Printf("%-20s %-14s %-8s %-4s %s\n", "ID", "STATUS", "VERSION", "INST", "DESCRIPTION")
fmt.Println(strings.Repeat("─", 78))
for _, s := range statuses {
fmt.Printf("%-20s %-12s %-8s %s\n",
fmt.Printf("%-20s %-14s %-8s %-4d %s\n",
s.ID,
statusLabel(s),
s.Version,
truncate(s.Desc, 36),
s.Instances,
truncate(s.Desc, 32),
)
}
return nil
@@ -112,18 +113,13 @@ func startCmd(mgr *process.Manager, binPath *string) *cobra.Command {
fmt.Printf("skip %-20s (disabled in config)\n", s.ID)
continue
}
if s.Running {
fmt.Printf("skip %-20s (already running, PID %d)\n", s.ID, s.PID)
continue
}
if err := mgr.Start(s.AgentInfo); err != nil {
fmt.Fprintf(os.Stderr, "fail %-20s %v\n", s.ID, err)
continue
}
fmt.Printf("start %-20s PID %d log → %s\n",
s.ID, mgr.ReadPID(s.ID), mgr.LogPath(s.ID))
fmt.Printf("start %-20s PID %d (instances: %d) log → %s\n",
s.ID, mgr.ReadPID(s.ID), mgr.InstanceCount(s.ID), mgr.LogPath(s.ID))
started++
}
@@ -244,6 +240,9 @@ func statusLabel(s process.AgentStatus) string {
case !s.Enabled:
return "disabled"
case s.Running:
if s.Instances > 1 {
return fmt.Sprintf("● running(%d)", s.Instances)
}
return "● running"
default:
return "○ stopped"