Skip to content

Commit

Permalink
Merge pull request #140 from codenrhoden/fix-graceful-stop
Browse files Browse the repository at this point in the history
Don't call grpc stop before server initialized
  • Loading branch information
codenrhoden committed Mar 25, 2020
2 parents b980094 + 0545aaf commit 97feea8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gocsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ func (sp *StoragePlugin) Serve(ctx context.Context, lis net.Listener) error {
// errors.
func (sp *StoragePlugin) Stop(ctx context.Context) {
sp.stopOnce.Do(func() {
sp.server.Stop()
if sp.server != nil {
sp.server.Stop()
}
log.Info("stopped")
})
}
Expand All @@ -330,7 +332,9 @@ func (sp *StoragePlugin) Stop(ctx context.Context) {
// pending RPCs are finished.
func (sp *StoragePlugin) GracefulStop(ctx context.Context) {
sp.stopOnce.Do(func() {
sp.server.GracefulStop()
if sp.server != nil {
sp.server.GracefulStop()
}
log.Info("gracefully stopped")
})
}
Expand Down

0 comments on commit 97feea8

Please sign in to comment.