[#1539] node: Support healthcheck server for gRPC services
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
2d5d4093be
commit
279549be94
4 changed files with 24 additions and 0 deletions
20
cmd/frostfs-node/grpc_health.go
Normal file
20
cmd/frostfs-node/grpc_health.go
Normal file
|
@ -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)
|
||||||
|
})
|
||||||
|
}
|
|
@ -117,6 +117,8 @@ func initApp(ctx context.Context, c *cfg) {
|
||||||
initAndLog(ctx, c, "control", func(c *cfg) { initControlService(ctx, c) })
|
initAndLog(ctx, c, "control", func(c *cfg) { initControlService(ctx, c) })
|
||||||
|
|
||||||
initAndLog(ctx, c, "morph notifications", func(c *cfg) { listenMorphNotifications(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)) {
|
func runAndLog(ctx context.Context, c *cfg, name string, logSuccess bool, starter func(context.Context, *cfg)) {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -2,6 +2,8 @@ module git.frostfs.info/TrueCloudLab/frostfs-node
|
||||||
|
|
||||||
go 1.22
|
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 (
|
require (
|
||||||
code.gitea.io/sdk/gitea v0.17.1
|
code.gitea.io/sdk/gitea v0.17.1
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.0-rc.4
|
git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.0-rc.4
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
Loading…
Reference in a new issue