feat: add restart subcommands to witness and refinery (gt-9kc2)

- Add `gt witness restart <rig>` command (stop + start)
- Add `gt refinery restart [rig]` command (stop + start)
- Add self-cycling documentation to refinery template
- Clarify that restarts are daemon-managed, not shell loops

🤖 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-23 03:56:31 -08:00
parent d51fe0268d
commit 46a5e38fa2
4 changed files with 129 additions and 7 deletions

View File

@@ -98,6 +98,21 @@ Examples:
RunE: runRefineryAttach,
}
var refineryRestartCmd = &cobra.Command{
Use: "restart [rig]",
Short: "Restart the refinery",
Long: `Restart the Refinery for a rig.
Stops the current session (if running) and starts a fresh one.
If rig is not specified, infers it from the current directory.
Examples:
gt refinery restart gastown
gt refinery restart # infer rig from cwd`,
Args: cobra.MaximumNArgs(1),
RunE: runRefineryRestart,
}
func init() {
// Start flags
refineryStartCmd.Flags().BoolVar(&refineryForeground, "foreground", false, "Run in foreground (default: background)")
@@ -111,6 +126,7 @@ func init() {
// Add subcommands
refineryCmd.AddCommand(refineryStartCmd)
refineryCmd.AddCommand(refineryStopCmd)
refineryCmd.AddCommand(refineryRestartCmd)
refineryCmd.AddCommand(refineryStatusCmd)
refineryCmd.AddCommand(refineryQueueCmd)
refineryCmd.AddCommand(refineryAttachCmd)
@@ -383,3 +399,31 @@ func runRefineryAttach(cmd *cobra.Command, args []string) error {
// Attach to session using exec to properly forward TTY
return attachToTmuxSession(sessionID)
}
func runRefineryRestart(cmd *cobra.Command, args []string) error {
rigName := ""
if len(args) > 0 {
rigName = args[0]
}
mgr, _, rigName, err := getRefineryManager(rigName)
if err != nil {
return err
}
fmt.Printf("Restarting refinery for %s...\n", rigName)
// Stop if running (ignore ErrNotRunning)
if err := mgr.Stop(); err != nil && err != refinery.ErrNotRunning {
return fmt.Errorf("stopping refinery: %w", err)
}
// Start fresh
if err := mgr.Start(false); err != nil {
return fmt.Errorf("starting refinery: %w", err)
}
fmt.Printf("%s Refinery restarted for %s\n", style.Bold.Render("✓"), rigName)
fmt.Printf(" %s\n", style.Dim.Render("Use 'gt refinery attach' to connect"))
return nil
}