Skip to content

Commit

Permalink
Add health checking endpoints to RPC server.
Browse files Browse the repository at this point in the history
See https://github.com/grpc/grpc/blob/master/doc/health-checking.md for
gRPC health checking documentataton.
  • Loading branch information
wlynch authored and tekton-robot committed Jan 20, 2021
1 parent db84611 commit 9622bbe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
v1alpha2pb "github.com/tektoncd/results/proto/v1alpha2/results_go_proto"

"google.golang.org/grpc"
"google.golang.org/grpc/health"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/reflection"
"gorm.io/driver/mysql"
"gorm.io/gorm"
Expand Down Expand Up @@ -59,6 +61,11 @@ func main() {
// Allow service reflection - required for grpc_cli ls to work.
reflection.Register(s)

// Set up health checks.
hs := health.NewServer()
hs.SetServingStatus("tekton.results.v1alpha2.Results", healthpb.HealthCheckResponse_SERVING)
healthpb.RegisterHealthServer(s, hs)

// Listen on port and serve.
port := os.Getenv("PORT")
if port == "" {
Expand Down

0 comments on commit 9622bbe

Please sign in to comment.