Skip to content

Commit

Permalink
Avoid showing the usage info when run fails
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-fritz committed May 25, 2024
1 parent 8c6d6e0 commit d880c70
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewRunCommand() *cobra.Command {
Short: "Run the exporter",
Long: `Run the exporter which exports the received values from all configured Group Addresses to prometheus.`,
Args: cobra.NoArgs,
RunE: runOptions.run,
Run: runOptions.run,
}

cmd.Flags().Uint16P("port", "p", 8080, "The port where all metrics should be exported.")
Expand All @@ -77,19 +77,22 @@ func NewRunCommand() *cobra.Command {
return &cmd
}

func (i *RunOptions) run(_ *cobra.Command, _ []string) error {
func (i *RunOptions) run(_ *cobra.Command, _ []string) {
exporter := metrics.NewExporter(uint16(viper.GetUint(RunPortParm)), viper.GetBool(WithGoMetricsParamName))

exporter.AddLivenessCheck("goroutine-threshold", healthcheck.GoroutineCountCheck(100))
metricsExporter, err := i.initAndRunMetricsExporter(exporter)
if err != nil {
return err
logrus.Error("Unable to init metrics exporter: ", err)
return
}

go i.aliveCheck(exporter, metricsExporter)

defer metricsExporter.Close()
return exporter.Run()
if err = exporter.Run(); err != nil {
logrus.Error("Can not run metrics exporter: ", err)
}
}

func (i *RunOptions) aliveCheck(exporter metrics.Exporter, metricsExporter knx.MetricsExporter) {
Expand Down

0 comments on commit d880c70

Please sign in to comment.