add debug server to activitylog & check web availability

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2024-10-14 08:39:42 +02:00
parent 0671039474
commit 26bf6ab796
4 changed files with 118 additions and 19 deletions
+17 -1
View File
@@ -1,6 +1,9 @@
package debug
import (
"context"
"fmt"
"net"
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/handlers"
@@ -14,7 +17,20 @@ func Server(opts ...Option) (*http.Server, error) {
checkHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger),
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
}),
)
return debug.NewService(