Extract daemon logic from cmd/daemon/ into internal/daemon/ package and create a new unified CLI entry point at cmd/multica/ using cobra. The CLI supports `daemon` as a long-running subcommand plus ctrl subcommands for agent/runtime management, config, status, and version. Server, migrate, and seed binaries remain unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
647 B
Go
36 lines
647 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var statusCmd = &cobra.Command{
|
|
Use: "status",
|
|
Short: "Check server health",
|
|
RunE: runStatus,
|
|
}
|
|
|
|
func runStatus(cmd *cobra.Command, _ []string) error {
|
|
client, err := newAPIClient(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
|
|
body, err := client.HealthCheck(ctx)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Server unreachable: %v\n", err)
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintf(os.Stdout, "Server: %s\n", client.BaseURL)
|
|
fmt.Fprintf(os.Stdout, "Status: %s\n", body)
|
|
return nil
|
|
}
|