Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.31 KB

README.md

File metadata and controls

50 lines (39 loc) · 1.31 KB

gracegrpc is used to wrap a grpc server that can be gracefully terminated & restarted.

LICENSE Build Status Go Report Card Godoc

Installation

go get github.com/0x5010/gracegrpc

Usage

Wrap grpc server and start server:

s := grpc.NewServer()
pb.RegisterDeployServer(s, &server{})
reflection.Register(s)
gr, err := gracegrpc.New(s, "tcp", addr, pidPath, nil)
if err != nil {
	log.Fatalf("failed to new gracegrpc: %v", err)
}
if err := gr.Serve(); err != nil {
	log.Fatalf("failed to serve: %v", err)
}

Custom logger

import log "github.com/sirupsen/logrus"

...
gr, err := gracegrpc.New(s, "tcp", addr, pidPath, log.StandardLogger())
...

In a terminal trigger a graceful server restart (using the pid from your output):

kill -USR2 pid

Run with supervisor

command = /path/to/pidproxy.py /path/to/pidPath /path/to/server

kill -USR2 {pidproxy.py pid}