grpchealth

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

grpchealth

A simple gRPC health check tool for testing and monitoring gRPC services.

Overview

grpchealth provides both server and client implementations of the gRPC Health Checking Protocol. It allows you to quickly spin up a health check server for testing or verify the health status of existing gRPC services.

Features

  • Server Mode: Run a standalone gRPC health check server

    • Support for TLS/SSL connections
    • Unix Domain Socket support
    • Graceful shutdown on interrupt signals
    • Configurable server address
  • Client Mode: Check health status of gRPC services

    • Support for TLS connections with certificate verification
    • Unix Domain Socket support
    • Insecure mode for testing (skip certificate verification)
    • Service-specific health checks
    • Connection timing information
    • Peer certificate information display

Installation

go install github.com/fujiwara/grpchealth/cmd/grpchealth@latest

Or build from source:

git clone https://github.com/fujiwara/grpchealth.git
cd grpchealth
make

Usage

Usage: grpchealth <command>

Flags:
  -h, --help    Show context-sensitive help.

Commands:
  server <address> [flags]
    Run gRPC health check server

  client <address> [flags]
    Run gRPC health check client

Run "grpchealth <command> --help" for more information on a command.
Server Mode

Start a basic gRPC health check server:

grpchealth server localhost:50051

Start a server with TLS:

grpchealth server localhost:50051 --cert-file server.crt --key-file server.key
Server Options
Usage: grpchealth server <address> [flags]

Run gRPC health check server

Arguments:
  <address>    gRPC server address

Flags:
  -h, --help                Show context-sensitive help.

  -c, --cert-file=STRING    Path to the server certificate file
  -k, --key-file=STRING     Path to the server key file
Client Mode

Check health of a gRPC service:

grpchealth client localhost:50051

Check with TLS:

grpchealth client localhost:50051 --tls

Check with TLS (skip certificate verification):

grpchealth client localhost:50051 --tls --insecure

Check specific service health:

grpchealth client localhost:50051 --service myservice
Client Options
Usage: grpchealth client <address> [flags]

Run gRPC health check client

Arguments:
  <address>    gRPC client address

Flags:
  -h, --help          Show context-sensitive help.

  -t, --tls           Use TLS for connection
  -k, --insecure      Use insecure connection
  -s, --service=""    Service name to check health status

Examples

Testing with a local server
  1. Start the health check server:
grpchealth server :50051
  1. In another terminal, check its health:
grpchealth client localhost:50051
Testing with TLS
  1. Generate self-signed certificates (for testing):
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes
  1. Start server with TLS:
grpchealth server :50051 --cert-file server.crt --key-file server.key
  1. Check health with TLS:
grpchealth client localhost:50051 --tls --insecure
Testing with Unix Domain Socket
  1. Start server with Unix Domain Socket:
grpchealth server unix:/tmp/grpc.sock
  1. In another terminal, check its health:
grpchealth client unix:/tmp/grpc.sock

Alternatively, you can use absolute paths directly:

grpchealth server /tmp/grpc.sock
grpchealth client /tmp/grpc.sock

Development

Building
make
Running tests
make test
Installing locally
make install
Creating distribution packages
make dist

License

See LICENSE file for details.

Author

Fujiwara Shunichiro

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context) error

Types

type CLI

type CLI struct {
	Server CLIServer `cmd:"" help:"Run gRPC health check server"`
	Client CLIClient `cmd:"" help:"Run gRPC health check client"`
}

type CLIClient

type CLIClient struct {
	Address  string `help:"gRPC client address (e.g., localhost:50051 or unix:///tmp/grpc.sock)" arg:"" required:""`
	TLS      bool   `help:"Use TLS for connection" short:"t"`
	Insecure bool   `help:"Use insecure connection" short:"k"`
	Service  string `help:"Service name to check health status" default:"" short:"s"`
}

type CLIServer

type CLIServer struct {
	Address  string `help:"gRPC server address (e.g., :50051 or unix:///tmp/grpc.sock)" arg:"" required:""`
	CertFile string `help:"Path to the server certificate file" short:"c"`
	KeyFile  string `help:"Path to the server key file" short:"k"`
}

Directories

Path Synopsis
cmd
grpchealth command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址