https://github.com/cdzombak/heartbeat
Simple HTTP heartbeat implementation for Golang
https://github.com/cdzombak/heartbeat
heartbeat uptime-kuma
Last synced: 4 months ago
JSON representation
Simple HTTP heartbeat implementation for Golang
- Host: GitHub
- URL: https://github.com/cdzombak/heartbeat
- Owner: cdzombak
- License: mit
- Created: 2023-11-14T13:48:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-15T02:18:09.000Z (11 months ago)
- Last Synced: 2025-01-15T18:42:19.512Z (6 months ago)
- Topics: heartbeat, uptime-kuma
- Language: Go
- Homepage: https://pkg.go.dev/github.com/cdzombak/heartbeat
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `github.com/cdzombak/heartbeat`
[](https://pkg.go.dev/github.com/cdzombak/heartbeat)
Simple HTTP heartbeat & health server implementation for Golang. This implementation works particularly well with [Uptime Kuma](https://github.com/louislam/uptime-kuma)'s push monitors.
## Installation
```shell
go get github.com/cdzombak/heartbeat
```## Usage
Create and start a Heartbeat client:
```go
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:
```go
hb.Alive(time.Now())
```## License
MIT; see `LICENSE` in this repository.
## Author
- Chris Dzombak ([dzombak.com](https://www.dzombak.com))
- [GitHub @cdzombak](https://www.github.com/cdzombak)