Files

39 lines
1.2 KiB
Go
Raw Permalink Normal View History

2019-12-10 09:38:51 +01:00
package debug
import (
"net/http"
"net/url"
2019-12-10 09:38:51 +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-10 09:38:51 +01:00
)
// Server initializes the debug service and server.
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
healthHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("http reachability", checks.NewHTTPCheck(options.Config.HTTP.Addr))
2024-10-15 13:47:39 +02:00
u, err := url.Parse(options.Config.Ldap.URI)
if err != nil {
return nil, err
}
readyHandlerConfiguration := healthHandlerConfiguration.
WithCheck("ldap reachability", checks.NewTCPCheck(u.Host))
2019-12-10 09:38:51 +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-10 09:38:51 +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),
debug.Health(handlers.NewCheckHandler(healthHandlerConfiguration)),
debug.Ready(handlers.NewCheckHandler(readyHandlerConfiguration)),
2019-12-10 09:38:51 +01:00
), nil
}