-
Notifications
You must be signed in to change notification settings - Fork 111
/
health-check.go
40 lines (32 loc) · 912 Bytes
/
health-check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package commands
import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/chef/automate/components/event-gateway/pkg/config"
"github.com/chef/automate/components/event-gateway/pkg/nats"
)
func newHealthCheckCommand() *cobra.Command {
var debug bool
cmd := &cobra.Command{
Use: "health-check",
Short: "Check the health of the event-gateway (NATS) server",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := config.Configure()
if err != nil {
return errors.Wrap(err, "reading event-gateway configuration")
}
if debug {
cfg.LogConfig.LogLevel = "debug"
cfg.SetLogLevel()
}
err = nats.ConnectivityCheck(cfg)
if err != nil {
return errors.Wrap(err, "checking connectivity")
}
return nil
},
}
cmd.PersistentFlags().BoolVar(&debug, "debug", false, "enable debug logging")
return cmd
}