Files

36 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-10-10 11:57:59 +02:00
package debug
import (
"net/http"
2024-10-14 16:50:58 +02:00
"strconv"
2024-10-10 11:57:59 +02:00
"github.com/owncloud/ocis/v2/ocis-pkg/checks"
2024-10-10 11:57:59 +02:00
"github.com/owncloud/ocis/v2/ocis-pkg/handlers"
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
)
// Server initializes the debug service and server.
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
2024-10-14 16:50:58 +02:00
// For nats readiness and liveness checks are identical
// the nats server will neither be healthy nor ready when it can not reach the nats server/cluster
2024-10-10 11:57:59 +02:00
checkHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
2024-10-14 16:50:58 +02:00
WithLogger(options.Logger).
WithCheck("nats reachability", checks.NewNatsCheck(options.Config.Nats.Host+":"+strconv.Itoa(options.Config.Nats.Port))),
2024-10-10 11:57:59 +02:00
)
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Config.Service.Name),
debug.Version(version.GetString()),
debug.Address(options.Config.Debug.Addr),
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),
debug.Health(checkHandler),
debug.Ready(checkHandler),
), nil
}