diff --git a/cmd/frostfs-node/grpc_health.go b/cmd/frostfs-node/grpc_health.go new file mode 100644 index 000000000..a2b50535c --- /dev/null +++ b/cmd/frostfs-node/grpc_health.go @@ -0,0 +1,20 @@ +package main + +import ( + "net" + + "google.golang.org/grpc" + "google.golang.org/grpc/health" + healthV1 "google.golang.org/grpc/health/grpc_health_v1" +) + +func initGRPCHealth(c *cfg) { + healthServer := health.NewServer() + c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, srv *grpc.Server) { + healthV1.RegisterHealthServer(srv, healthServer) + healthServer.SetServingStatus("", healthV1.HealthCheckResponse_SERVING) + }) + c.onShutdown(func() { + healthServer.SetServingStatus("", healthV1.HealthCheckResponse_NOT_SERVING) + }) +} diff --git a/cmd/frostfs-node/main.go b/cmd/frostfs-node/main.go index f8854ab3c..28f09c5e2 100644 --- a/cmd/frostfs-node/main.go +++ b/cmd/frostfs-node/main.go @@ -117,6 +117,8 @@ func initApp(ctx context.Context, c *cfg) { initAndLog(ctx, c, "control", func(c *cfg) { initControlService(ctx, c) }) initAndLog(ctx, c, "morph notifications", func(c *cfg) { listenMorphNotifications(ctx, c) }) + + initAndLog(ctx, c, "grpc_health", initGRPCHealth) } func runAndLog(ctx context.Context, c *cfg, name string, logSuccess bool, starter func(context.Context, *cfg)) { diff --git a/go.mod b/go.mod index c538a3178..054f7da1c 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module git.frostfs.info/TrueCloudLab/frostfs-node go 1.22 +replace git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20241107121119-cb813e27a823 => git.frostfs.info/aarifullin/frostfs-sdk-go v0.0.0-20241204121743-ab885d24496a + require ( code.gitea.io/sdk/gitea v0.17.1 git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.0-rc.4 diff --git a/go.sum b/go.sum index 064f3274e..3b674d503 100644 Binary files a/go.sum and b/go.sum differ