Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ type ClientConfig struct {
// to create gRPC connections. This only affects plugins using the gRPC
// protocol.
GRPCDialOptions []grpc.DialOption

// GracefulStopTimeout is the timeout to wait for the plugin stop.
GracefulStopTimeout time.Duration
}

// ReattachConfig is used to configure a client to reattach to an
Expand Down Expand Up @@ -326,6 +329,10 @@ func NewClient(config *ClientConfig) (c *Client) {
if config.AllowedProtocols == nil {
config.AllowedProtocols = []Protocol{ProtocolNetRPC}
}

if config.GracefulStopTimeout == 0 {
config.GracefulStopTimeout = 2 * time.Second
}

if config.Logger == nil {
config.Logger = hclog.New(&hclog.LoggerOptions{
Expand Down Expand Up @@ -460,7 +467,7 @@ func (c *Client) Kill() {
case <-c.doneCtx.Done():
c.logger.Debug("plugin exited")
return
case <-time.After(2 * time.Second):
case <-time.After(c.config.GracefulStopTimeout):
}
}

Expand Down
3 changes: 1 addition & 2 deletions grpc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type grpcControllerServer struct {
func (s *grpcControllerServer) Shutdown(ctx context.Context, _ *plugin.Empty) (*plugin.Empty, error) {
resp := &plugin.Empty{}

// TODO: figure out why GracefullStop doesn't work.
s.server.Stop()
go s.server.GracefulStop()
return resp, nil
}