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

Method StartIfExist

backend/component/sampleinstance/manager.go:48–71  ·  view source on GitHub ↗

StartIfExist starts sample instances if they exist in the database.

(ctx context.Context, workspaceID string)

Source from the content-addressed store, hash-verified

46
47// StartIfExist starts sample instances if they exist in the database.
48func (m *Manager) StartIfExist(ctx context.Context, workspaceID string) error {
49 // Check if sample instances exist in the database
50 hasSampleInstances, err := m.store.HasSampleInstances(ctx, workspaceID)
51 if err != nil {
52 slog.Warn("failed to check for sample instances", log.BBError(err))
53 return nil // Non-fatal error
54 }
55
56 if !hasSampleInstances {
57 slog.Info("no sample instances found in database, skipping sample instance startup")
58 return nil
59 }
60
61 // Start all sample instances
62 slog.Info("starting sample instances")
63 stoppers := postgres.StartAllSampleInstances(ctx, m.profile.DataDir, m.port)
64
65 m.mu.Lock()
66 defer m.mu.Unlock()
67
68 m.stoppers = stoppers
69
70 return nil
71}
72
73// HandleInstanceDeletion handles the deletion of a sample instance.
74// We stop all sample instances only when both have been deleted.

Callers 1

NewServerFunction · 0.80

Calls 4

BBErrorFunction · 0.92
StartAllSampleInstancesFunction · 0.92
HasSampleInstancesMethod · 0.80
InfoMethod · 0.80

Tested by

no test coverage detected