refactor: add timeout to server closing
parent
5a8da7ce9e
commit
e854597382
|
@ -10,6 +10,7 @@ import (
|
||||||
"google.golang.org/grpc/health"
|
"google.golang.org/grpc/health"
|
||||||
"google.golang.org/grpc/health/grpc_health_v1"
|
"google.golang.org/grpc/health/grpc_health_v1"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
@ -49,6 +50,7 @@ func (s *Server) Listen(addr string) error {
|
||||||
|
|
||||||
func (s *Server) Close() error {
|
func (s *Server) Close() error {
|
||||||
s.healthSrv.Shutdown()
|
s.healthSrv.Shutdown()
|
||||||
|
time.Sleep(5 * time.Second) // Set a timeout in which all services will be marked as unhealthy
|
||||||
|
|
||||||
s.grpcSrv.GracefulStop()
|
s.grpcSrv.GracefulStop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue