go-healthchecks/cmd/start.go

31 lines
580 B
Go
Raw Normal View History

2024-10-02 13:26:14 +00:00
package main
import (
"fmt"
"os"
gohealthchecks "git.faercol.me/faercol/go-healthchecks"
"github.com/spf13/cobra"
)
var startCmd = &cobra.Command{
Use: "start",
Short: "Signal the check has started",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
check := parseCheckFlags()
clt := gohealthchecks.NewPingClient(pingHost)
err := clt.ReportStart(cmd.Context(), check)
if err != nil {
failf("Failed to notify start: %s\n", err)
} else {
fmt.Println("Notified check start")
os.Exit(0)
}
},
}
func init() {
rootCmd.AddCommand(startCmd)
}