Skip to content

Commit

Permalink
Add grpc health check service
Browse files Browse the repository at this point in the history
Fixes: containerd#615

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
  • Loading branch information
hqhq committed Mar 14, 2017
1 parent a160a6a commit e663cbd
Show file tree
Hide file tree
Showing 6 changed files with 281 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/containerd/builtins.go
Expand Up @@ -5,6 +5,7 @@ import (
_ "github.com/docker/containerd/linux"
_ "github.com/docker/containerd/services/content"
_ "github.com/docker/containerd/services/execution"
_ "github.com/docker/containerd/services/healthcheck"
_ "github.com/docker/containerd/snapshot/btrfs"
_ "github.com/docker/containerd/snapshot/overlay"
)
1 change: 1 addition & 0 deletions cmd/containerd/main.go
Expand Up @@ -125,6 +125,7 @@ func main() {
return err
}
}
log.G(global).Info("starting GRPC API server...")
if err := serveGRPC(server); err != nil {
return err
}
Expand Down
31 changes: 31 additions & 0 deletions services/healthcheck/service.go
@@ -0,0 +1,31 @@
package healthcheck

import (
"github.com/docker/containerd/plugin"

"google.golang.org/grpc"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
)

type Service struct {
serve *health.Server
}

func init() {
plugin.Register("healthcheck-grpc", &plugin.Registration{
Type: plugin.GRPCPlugin,
Init: NewService,
})
}

func NewService(ic *plugin.InitContext) (interface{}, error) {
return &Service{
health.NewServer(),
}, nil
}

func (s *Service) Register(server *grpc.Server) error {
grpc_health_v1.RegisterHealthServer(server, s.serve)
return nil
}
176 changes: 176 additions & 0 deletions vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/google.golang.org/grpc/health/grpc_health_v1/health.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions vendor/google.golang.org/grpc/health/health.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e663cbd

Please sign in to comment.