Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: grpc server 10 sec shutdown period (#6485)
Danny Xu9284dff71e69
diff --git a/backend/server/server.go b/backend/server/server.goindex bfdf22fe74..2dcb6729db 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -135,8 +135,9 @@ const (// webhookAPIPrefix is the API prefix for Bytebase webhook.webhookAPIPrefix = "/hook"// openAPIPrefix is the API prefix for Bytebase OpenAPI.- openAPIPrefix = "/v1"- maxStacksize = 8 * 1024+ openAPIPrefix = "/v1"+ maxStacksize = 8 * 1024+ gracefulShutdownPeriod = 10 * time.Second)// Server is the Bytebase server.@@ -893,7 +894,7 @@ func (s *Server) Shutdown(ctx context.Context) error {s.MetricReporter.Close()}- ctx, cancel := context.WithTimeout(ctx, 10*time.Second)+ ctx, cancel := context.WithTimeout(ctx, gracefulShutdownPeriod)defer cancel()// Cancel the worker@@ -908,7 +909,19 @@ func (s *Server) Shutdown(ctx context.Context) error {}}if s.grpcServer != nil {- s.grpcServer.GracefulStop()+ stopped := make(chan struct{})+ go func() {+ s.grpcServer.GracefulStop()+ close(stopped)+ }()++ t := time.NewTimer(gracefulShutdownPeriod)+ select {+ case <-t.C:+ s.grpcServer.Stop()+ case <-stopped:+ t.Stop()+ }}// Wait for all runners to exit.