Merge pull request #300 from apfm-cabe-waldrop/fix/shutdown-stop-daemon
Fix gt shutdown to stop daemon
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/steveyegge/gastown/internal/config"
|
||||
"github.com/steveyegge/gastown/internal/constants"
|
||||
"github.com/steveyegge/gastown/internal/crew"
|
||||
"github.com/steveyegge/gastown/internal/daemon"
|
||||
"github.com/steveyegge/gastown/internal/deacon"
|
||||
"github.com/steveyegge/gastown/internal/git"
|
||||
"github.com/steveyegge/gastown/internal/mayor"
|
||||
@@ -473,6 +474,12 @@ func runGracefulShutdown(t *tmux.Tmux, gtSessions []string, townRoot string) err
|
||||
cleanupPolecats(townRoot)
|
||||
}
|
||||
|
||||
// Phase 6: Stop the daemon
|
||||
fmt.Printf("\nPhase 6: Stopping daemon...\n")
|
||||
if townRoot != "" {
|
||||
stopDaemonIfRunning(townRoot)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Printf("%s Graceful shutdown complete (%d sessions stopped)\n", style.Bold.Render("✓"), stopped)
|
||||
return nil
|
||||
@@ -492,6 +499,13 @@ func runImmediateShutdown(t *tmux.Tmux, gtSessions []string, townRoot string) er
|
||||
cleanupPolecats(townRoot)
|
||||
}
|
||||
|
||||
// Stop the daemon
|
||||
if townRoot != "" {
|
||||
fmt.Println()
|
||||
fmt.Println("Stopping daemon...")
|
||||
stopDaemonIfRunning(townRoot)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Printf("%s Gas Town shutdown complete (%d sessions stopped)\n", style.Bold.Render("✓"), stopped)
|
||||
|
||||
@@ -641,6 +655,21 @@ func cleanupPolecats(townRoot string) {
|
||||
}
|
||||
}
|
||||
|
||||
// stopDaemonIfRunning stops the daemon if it is running.
|
||||
// This prevents the daemon from restarting agents after shutdown.
|
||||
func stopDaemonIfRunning(townRoot string) {
|
||||
running, _, _ := daemon.IsRunning(townRoot)
|
||||
if running {
|
||||
if err := daemon.StopDaemon(townRoot); err != nil {
|
||||
fmt.Printf(" %s Daemon: %s\n", style.Dim.Render("○"), err.Error())
|
||||
} else {
|
||||
fmt.Printf(" %s Daemon stopped\n", style.Bold.Render("✓"))
|
||||
}
|
||||
} else {
|
||||
fmt.Printf(" %s Daemon not running\n", style.Dim.Render("○"))
|
||||
}
|
||||
}
|
||||
|
||||
// runStartCrew starts a crew workspace, creating it if it doesn't exist.
|
||||
// This combines the functionality of 'gt crew add' and 'gt crew at --detached'.
|
||||
func runStartCrew(cmd *cobra.Command, args []string) error {
|
||||
|
||||
Reference in New Issue
Block a user