StartIfExist starts sample instances if they exist in the database.
(ctx context.Context, workspaceID string)
| 46 | |
| 47 | // StartIfExist starts sample instances if they exist in the database. |
| 48 | func (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. |
no test coverage detected