cmd: graceful close the connection

This commit is contained in:
c9s 2021-12-23 14:21:26 +08:00
parent 562c287a4e
commit e2415857b0

View File

@ -58,7 +58,12 @@ var userDataStreamCmd = &cobra.Command{
}
log.Infof("connected")
defer s.Close()
defer func() {
log.Infof("closing connection...")
if err := s.Close(); err != nil {
log.WithError(err).Errorf("connection close error")
}
}()
cmdutil.WaitForSignal(ctx, syscall.SIGINT, syscall.SIGTERM)
return nil