refactor web & activitylog checks

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2024-10-15 13:41:31 +02:00
parent 9186c90bd8
commit c11b18c833
2 changed files with 6 additions and 21 deletions

View File

@@ -14,13 +14,15 @@ func Server(opts ...Option) (*http.Server, error) {
healthHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger),
WithLogger(options.Logger).
WithCheck("http reachability", handlers.NewHTTPCheck(options.Config.HTTP.Addr)),
)
readyHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)),
WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)).
WithInheritedChecksFrom(healthHandler.Conf),
)
return debug.NewService(

View File

@@ -1,14 +1,10 @@
package debug
import (
"context"
"fmt"
"net"
"net/http"
"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"
"net/http"
)
// Server initializes the debug service and server.
@@ -17,20 +13,7 @@ func Server(opts ...Option) (*http.Server, error) {
checkHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).WithCheck("web reachability", func(ctx context.Context) error {
conn, err := net.Dial("tcp", options.Config.HTTP.Addr)
defer func(conn net.Conn) {
err := conn.Close()
if err != nil {
return
}
}(conn)
if err != nil {
return fmt.Errorf("could not connect to web server: %v", err)
}
return nil
}),
WithLogger(options.Logger).WithCheck("web reachability", handlers.NewHTTPCheck(options.Config.HTTP.Addr)),
)
return debug.NewService(