feat: add rebuild and restart functionality for agents, including build process and status reporting
This commit is contained in:
+18
-4
@@ -16,10 +16,11 @@ const (
|
||||
IntentQuit IntentKind = "quit"
|
||||
|
||||
// Server-wide bulk operations
|
||||
IntentStartAll IntentKind = "start_all"
|
||||
IntentStopAll IntentKind = "stop_all"
|
||||
IntentRestartAll IntentKind = "restart_all"
|
||||
IntentKillAll IntentKind = "kill_all"
|
||||
IntentStartAll IntentKind = "start_all"
|
||||
IntentStopAll IntentKind = "stop_all"
|
||||
IntentRestartAll IntentKind = "restart_all"
|
||||
IntentKillAll IntentKind = "kill_all"
|
||||
IntentRebuildRestart IntentKind = "rebuild_restart"
|
||||
)
|
||||
|
||||
// Intent is pure data describing a side effect to execute.
|
||||
@@ -67,6 +68,16 @@ func Update(model Model, msg interface{}) (Model, []Intent) {
|
||||
}
|
||||
return model, []Intent{{Kind: IntentLoadAgents}}
|
||||
|
||||
case MsgRebuildDone:
|
||||
if !m.BuildOK {
|
||||
model.StatusMsg = fmt.Sprintf("Build failed: %s", m.BuildLog)
|
||||
} else if m.Failed > 0 {
|
||||
model.StatusMsg = fmt.Sprintf("Built OK, %d/%d agents failed to restart", m.Failed, m.Restarted+m.Failed)
|
||||
} else {
|
||||
model.StatusMsg = fmt.Sprintf("Built OK, %d agents restarted", m.Restarted)
|
||||
}
|
||||
return model, []Intent{{Kind: IntentLoadAgents}}
|
||||
|
||||
case MsgServerActionDone:
|
||||
if m.Failed == 0 {
|
||||
model.StatusMsg = fmt.Sprintf("%s: %d agents OK", m.Action, m.Total)
|
||||
@@ -267,6 +278,9 @@ func executeServerAction(model Model, action string) (Model, []Intent) {
|
||||
case "Kill All":
|
||||
model.StatusMsg = "Killing all agents..."
|
||||
return model, []Intent{{Kind: IntentKillAll}}
|
||||
case "Rebuild & Restart":
|
||||
model.StatusMsg = "Building & restarting..."
|
||||
return model, []Intent{{Kind: IntentRebuildRestart}}
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user