Skip to content

Commit 97feea8

Browse files
authored
Merge pull request #140 from codenrhoden/fix-graceful-stop
Don't call grpc stop before server initialized
2 parents b980094 + 0545aaf commit 97feea8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gocsi.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ func (sp *StoragePlugin) Serve(ctx context.Context, lis net.Listener) error {
320320
// errors.
321321
func (sp *StoragePlugin) Stop(ctx context.Context) {
322322
sp.stopOnce.Do(func() {
323-
sp.server.Stop()
323+
if sp.server != nil {
324+
sp.server.Stop()
325+
}
324326
log.Info("stopped")
325327
})
326328
}
@@ -330,7 +332,9 @@ func (sp *StoragePlugin) Stop(ctx context.Context) {
330332
// pending RPCs are finished.
331333
func (sp *StoragePlugin) GracefulStop(ctx context.Context) {
332334
sp.stopOnce.Do(func() {
333-
sp.server.GracefulStop()
335+
if sp.server != nil {
336+
sp.server.GracefulStop()
337+
}
334338
log.Info("gracefully stopped")
335339
})
336340
}

0 commit comments

Comments
 (0)