Documentation ¶
Overview ¶
Package cmd provides the command line interface for the guard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GuardInfoCommand = &cli.Command{ Name: "guard-info", Description: "learn how to use guard cli", Action: func(c *cli.Context) error { fmt.Println(string(markdown.Render(help, termsize.Width(), 6))) return nil }, }
GuardInfoCommand gets info about using the guard agent.
View Source
var GuardRunCommand = &cli.Command{ Name: "guard-run", Description: "runs the guard service", Flags: []cli.Flag{configFlag, metricsPortFlag, ignoreInitErrorsFlag}, Action: func(c *cli.Context) error { handler, err := metrics.NewFromEnv(c.Context, metadata.BuildInfo()) if err != nil { return fmt.Errorf("failed to create metrics handler: %w", err) } guardConfig, err := config.DecodeAgentConfig(core.ExpandOrReturnPath(c.String(configFlag.Name))) if err != nil { return fmt.Errorf("failed to decode config: %w", err) } var shouldRetryAtomic atomic.Bool shouldRetryAtomic.Store(true) for shouldRetryAtomic.Load() { shouldRetryAtomic.Store(false) g, _ := errgroup.WithContext(c.Context) guard, err := guard.NewGuard(c.Context, guardConfig, handler) if err != nil && !c.Bool(ignoreInitErrorsFlag.Name) { return fmt.Errorf("failed to create guard: %w", err) } g.Go(func() error { err = guard.Start(c.Context) if err != nil { shouldRetryAtomic.Store(true) log.Errorf("Error running guard, will sleep for a minute and retry: %v", err) time.Sleep(60 * time.Second) return fmt.Errorf("failed to run guard: %w", err) } return nil }) g.Go(func() error { err := api.Start(c.Context, uint16(c.Uint(metricsPortFlag.Name))) if err != nil { return fmt.Errorf("failed to start api: %w", err) } return nil }) if err := g.Wait(); err != nil { return fmt.Errorf("failed to run guard: %w", err) } } return nil }, }
GuardRunCommand runs the guard.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.