MCPcopy Index your code
hub / github.com/bytebase/bytebase / Shutdown

Method Shutdown

backend/server/server.go:311–351  ·  view source on GitHub ↗

Shutdown will shut down the server.

(ctx context.Context)

Source from the content-addressed store, hash-verified

309
310// Shutdown will shut down the server.
311func (s *Server) Shutdown(ctx context.Context) error {
312 slog.Info("Stopping Bytebase...")
313 slog.Info("Stopping web server...")
314
315 ctx, cancel := context.WithTimeout(ctx, gracefulShutdownPeriod)
316 defer cancel()
317
318 // Cancel the worker
319 if s.cancel != nil {
320 s.cancel()
321 }
322
323 // Shutdown HTTP server
324 if s.httpServer != nil {
325 if err := s.httpServer.Shutdown(ctx); err != nil {
326 slog.Error("Failed to shutdown HTTP server", log.BBError(err))
327 }
328 }
329
330 // Wait for all runners to exit.
331 s.runnerWG.Wait()
332
333 // Close db connection
334 if s.store != nil {
335 if err := s.store.Close(); err != nil {
336 return err
337 }
338 }
339
340 // Shutdown sample instances
341 if s.sampleInstanceManager != nil {
342 s.sampleInstanceManager.Stop()
343 }
344
345 // Shutdown postgres instances.
346 for _, stopper := range s.stopper {
347 stopper()
348 }
349
350 return nil
351}

Callers 3

NewServerFunction · 0.95
startFunction · 0.95
CloseMethod · 0.80

Calls 6

BBErrorFunction · 0.92
cancelFunction · 0.85
InfoMethod · 0.80
StopMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected