feat: add gt mayor restart command
Complete the mayor command set for GGT cutover. Now have: start, stop, attach, status, restart. Skipped wake-queue as it's part of the pooling model being deprecated in favor of ephemeral polecats (gt-7ik). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,11 +62,21 @@ var mayorStatusCmd = &cobra.Command{
|
||||
RunE: runMayorStatus,
|
||||
}
|
||||
|
||||
var mayorRestartCmd = &cobra.Command{
|
||||
Use: "restart",
|
||||
Short: "Restart the Mayor session",
|
||||
Long: `Restart the Mayor tmux session.
|
||||
|
||||
Stops the current session (if running) and starts a fresh one.`,
|
||||
RunE: runMayorRestart,
|
||||
}
|
||||
|
||||
func init() {
|
||||
mayorCmd.AddCommand(mayorStartCmd)
|
||||
mayorCmd.AddCommand(mayorStopCmd)
|
||||
mayorCmd.AddCommand(mayorAttachCmd)
|
||||
mayorCmd.AddCommand(mayorStatusCmd)
|
||||
mayorCmd.AddCommand(mayorRestartCmd)
|
||||
|
||||
rootCmd.AddCommand(mayorCmd)
|
||||
}
|
||||
@@ -208,3 +218,25 @@ func runMayorStatus(cmd *cobra.Command, args []string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func runMayorRestart(cmd *cobra.Command, args []string) error {
|
||||
t := tmux.NewTmux()
|
||||
|
||||
// Stop if running
|
||||
running, err := t.HasSession(MayorSessionName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("checking session: %w", err)
|
||||
}
|
||||
if running {
|
||||
fmt.Println("Stopping Mayor session...")
|
||||
t.SendKeysRaw(MayorSessionName, "C-c")
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if err := t.KillSession(MayorSessionName); err != nil {
|
||||
return fmt.Errorf("killing session: %w", err)
|
||||
}
|
||||
fmt.Printf("%s Mayor session stopped.\n", style.Bold.Render("✓"))
|
||||
}
|
||||
|
||||
// Start fresh
|
||||
return runMayorStart(cmd, args)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user