feat: add bd daemon --stop-all to kill all daemon processes (bd-47tn)

Add --stop-all flag to bd daemon command that:
- Discovers all running bd daemon processes using the registry
- Gracefully stops them all (with force kill fallback)
- Reports how many were stopped

Useful for:
- Cleaning up multiple daemons causing race conditions
- Getting a clean slate before running bd sync
- Debugging daemon-related issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-14 17:32:54 -08:00
parent ce80664005
commit dbbf338a12
2 changed files with 63 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ Common operations:
bd daemon --start Start the daemon (background)
bd daemon --start --foreground Start in foreground (for systemd/supervisord)
bd daemon --stop Stop a running daemon
bd daemon --stop-all Stop ALL running bd daemons
bd daemon --status Check if daemon is running
bd daemon --health Check daemon health and metrics
@@ -43,6 +44,7 @@ Run 'bd daemon' with no flags to see available options.`,
Run: func(cmd *cobra.Command, args []string) {
start, _ := cmd.Flags().GetBool("start")
stop, _ := cmd.Flags().GetBool("stop")
stopAll, _ := cmd.Flags().GetBool("stop-all")
status, _ := cmd.Flags().GetBool("status")
health, _ := cmd.Flags().GetBool("health")
metrics, _ := cmd.Flags().GetBool("metrics")
@@ -54,7 +56,7 @@ Run 'bd daemon' with no flags to see available options.`,
foreground, _ := cmd.Flags().GetBool("foreground")
// If no operation flags provided, show help
if !start && !stop && !status && !health && !metrics {
if !start && !stop && !stopAll && !status && !health && !metrics {
_ = cmd.Help()
return
}
@@ -119,6 +121,11 @@ Run 'bd daemon' with no flags to see available options.`,
return
}
if stopAll {
stopAllDaemons()
return
}
// If we get here and --start wasn't provided, something is wrong
// (should have been caught by help check above)
if !start {
@@ -222,6 +229,7 @@ func init() {
daemonCmd.Flags().Bool("auto-push", false, "Automatically push commits")
daemonCmd.Flags().Bool("local", false, "Run in local-only mode (no git required, no sync)")
daemonCmd.Flags().Bool("stop", false, "Stop running daemon")
daemonCmd.Flags().Bool("stop-all", false, "Stop all running bd daemons")
daemonCmd.Flags().Bool("status", false, "Show daemon status")
daemonCmd.Flags().Bool("health", false, "Check daemon health and metrics")
daemonCmd.Flags().Bool("metrics", false, "Show detailed daemon metrics")