mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-12 16:58:41 -05:00
refactor web & activitylog checks
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user