Files
ocis/services/graph/pkg/server/debug/server.go
T

41 lines
1.3 KiB
Go
Raw Normal View History

2019-12-04 17:15:11 +01:00
package debug
import (
"net/http"
"net/url"
2019-12-04 17:15:11 +01:00
"github.com/owncloud/ocis/v2/ocis-pkg/checks"
"github.com/owncloud/ocis/v2/ocis-pkg/handlers"
2022-05-04 14:49:59 +02:00
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
2019-12-04 17:15:11 +01:00
)
2019-12-06 13:14:21 +01:00
// Server initializes the debug service and server.
2019-12-04 17:15:11 +01:00
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
2024-10-17 16:13:18 +02:00
healthHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("web reachability", checks.NewHTTPCheck(options.Config.HTTP.Addr))
u, err := url.Parse(options.Config.Identity.LDAP.URI)
if err != nil {
return nil, err
}
2024-10-17 16:13:18 +02:00
readyHandlerConfiguration := healthHandlerConfiguration.
2024-10-18 17:30:39 +02:00
WithCheck("nats reachability", checks.NewNatsCheck(options.Config.Events.Endpoint)).
WithCheck("ldap reachability", checks.NewTCPCheck(u.Host))
2019-12-06 13:14:21 +01:00
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Config.Service.Name),
2022-06-13 10:41:14 +02:00
debug.Version(version.GetString()),
2019-12-06 13:14:21 +01:00
debug.Address(options.Config.Debug.Addr),
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),
2024-10-17 16:13:18 +02:00
debug.Health(handlers.NewCheckHandler(healthHandlerConfiguration)),
debug.Ready(handlers.NewCheckHandler(readyHandlerConfiguration)),
2019-12-06 13:14:21 +01:00
), nil
}