Simple HTTP heartbeat & health server implementation for Golang. This implementation works particularly well with Uptime Kuma's push monitors.
go get github.com/cdzombak/heartbeat
Create and start a Heartbeat client:
hb, err = NewHeartbeat(&HeartbeatConfig{
HeartbeatInterval: 30 * time.Second,
LivenessThreshold: 60 * time.Second,
HeartbeatURL: "https://uptimekuma.example.com:9001/api/push/1234abcd?status=up&msg=OK&ping=",
Port: 8888,
OnError: func(err error) {
log.Printf("heartbeat error: %s", err)
},
})
if err != nil {
panic(err)
}
// other program setup might go here
hb.Start()
Then, in your program's main loop/ticker/event handler, call Alive
periodically to indicate that everything's working:
hb.Alive(time.Now())
MIT; see LICENSE
in this repository.
- Chris Dzombak (dzombak.com)