checks added

This commit is contained in:
Roman Perekhod
2024-10-17 19:03:14 +02:00
parent 061c18056a
commit c16a2ea2cf
13 changed files with 114 additions and 23 deletions
@@ -1,8 +1,11 @@
package debug
import (
"context"
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/checks"
"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"
)
@@ -11,6 +14,15 @@ import (
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
readyHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("nats reachability", func(ctx context.Context) error {
if len(options.Config.Cache.ProviderCacheNodes) > 0 {
return checks.NewNatsCheck(options.Config.Cache.ProviderCacheNodes[0])(ctx)
}
return nil
})
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Config.Service.Name),
@@ -19,6 +31,7 @@ func Server(opts ...Option) (*http.Server, error) {
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),
debug.Ready(handlers.NewCheckHandler(readyHandlerConfiguration)),
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),