Added healthchecking via HTTP
Signed-off-by: Mathias Kaufmann <me@stei.gr>
This commit is contained in:
parent
c8e83bb840
commit
154aaa5243
16
goircd.go
16
goircd.go
@ -29,6 +29,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
healthchecking "github.com/heptiolabs/healthcheck"
|
||||||
"github.com/namsral/flag"
|
"github.com/namsral/flag"
|
||||||
|
|
||||||
proxyproto "github.com/Freeaqingme/go-proxyproto"
|
proxyproto "github.com/Freeaqingme/go-proxyproto"
|
||||||
@ -38,6 +39,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
PROXY_TIMEOUT = 5
|
PROXY_TIMEOUT = 5
|
||||||
|
HEALTCHECK_PORT = 8080
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -54,6 +56,7 @@ var (
|
|||||||
proxyTimeout = flag.Uint("proxytimeout", PROXY_TIMEOUT, "Timeout when using proxy protocol")
|
proxyTimeout = flag.Uint("proxytimeout", PROXY_TIMEOUT, "Timeout when using proxy protocol")
|
||||||
metrics = flag.Bool("metrics", false, "Enable metrics export")
|
metrics = flag.Bool("metrics", false, "Enable metrics export")
|
||||||
verbose = flag.Bool("v", false, "Enable verbose logging.")
|
verbose = flag.Bool("v", false, "Enable verbose logging.")
|
||||||
|
healtcheck = flag.Bool("healthcheck", false, "Enable healthcheck endpoint.")
|
||||||
|
|
||||||
clients_tls_total = prometheus.NewCounter(
|
clients_tls_total = prometheus.NewCounter(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
@ -190,10 +193,23 @@ func Run() {
|
|||||||
if *metrics {
|
if *metrics {
|
||||||
go prom_export()
|
go prom_export()
|
||||||
}
|
}
|
||||||
|
if *healtcheck {
|
||||||
|
go health_endpoint()
|
||||||
|
}
|
||||||
|
|
||||||
Processor(events, make(chan struct{}))
|
Processor(events, make(chan struct{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func health_endpoint() {
|
||||||
|
var (
|
||||||
|
health_bind = "0.0.0.0:8086"
|
||||||
|
)
|
||||||
|
health := healthchecking.NewHandler()
|
||||||
|
health.AddLivenessCheck("goroutine-threshold", healthchecking.GoroutineCountCheck(100))
|
||||||
|
log.Printf("Healthcheck listening on http://%s", health_bind)
|
||||||
|
http.ListenAndServe(health_bind, health)
|
||||||
|
}
|
||||||
|
|
||||||
func prom_export() {
|
func prom_export() {
|
||||||
prometheus.MustRegister(clients_tls_total)
|
prometheus.MustRegister(clients_tls_total)
|
||||||
prometheus.MustRegister(clients_irc_total)
|
prometheus.MustRegister(clients_irc_total)
|
||||||
|
Loading…
Reference in New Issue
Block a user