package cmd import ( "context" "fmt" "os/signal" "syscall" "github.com/spf13/cobra" app "anchorage/internal/app/anchorage" "anchorage/internal/pkg/config" ) // newServeCmd runs the anchorage server. func newServeCmd(flags *globalFlags) *cobra.Command { return &cobra.Command{ Use: "serve", Short: "Run the anchorage HTTP + cluster coordinator", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, _ []string) error { cfg, err := config.Load(config.LoadOptions{Path: flags.configPath, AllowMissing: true}) if err != nil { return fmt.Errorf("load config: %w", err) } ctx, stop := signal.NotifyContext(cmd.Context(), syscall.SIGINT, syscall.SIGTERM) defer stop() a, err := app.New(ctx, cfg) if err != nil { return fmt.Errorf("init app: %w", err) } defer a.Close(context.Background()) return a.Run(ctx) }, } }