(ctx context.Context, runInCurrentShell, allProjects bool, serviceNames ...string)
| 57 | } |
| 58 | |
| 59 | func (d *Devbox) StopServices(ctx context.Context, runInCurrentShell, allProjects bool, serviceNames ...string) error { |
| 60 | if !runInCurrentShell { |
| 61 | args := []string{"stop", "--run-in-current-shell"} |
| 62 | args = append(args, serviceNames...) |
| 63 | if allProjects { |
| 64 | args = append(args, "--all-projects") |
| 65 | } |
| 66 | return d.runDevboxServicesScript(ctx, args) |
| 67 | } |
| 68 | |
| 69 | if allProjects { |
| 70 | return services.StopAllProcessManagers(ctx, d.stderr) |
| 71 | } |
| 72 | |
| 73 | if !services.ProcessManagerIsRunning(d.projectDir) { |
| 74 | return usererr.New("Process manager is not running. Run `devbox services up` to start it.") |
| 75 | } |
| 76 | |
| 77 | if len(serviceNames) == 0 { |
| 78 | return services.StopProcessManager(ctx, d.projectDir, d.stderr) |
| 79 | } |
| 80 | |
| 81 | svcSet, err := d.Services() |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | for _, s := range serviceNames { |
| 87 | if _, ok := svcSet[s]; !ok { |
| 88 | return usererr.New("Service %s not found in your project", s) |
| 89 | } |
| 90 | err := services.StopServices(ctx, s, d.projectDir, d.stderr) |
| 91 | if err != nil { |
| 92 | fmt.Fprintf(d.stderr, "Error stopping service %s: %s", s, err) |
| 93 | } |
| 94 | } |
| 95 | return nil |
| 96 | } |
| 97 | |
| 98 | func (d *Devbox) ListServices(ctx context.Context, runInCurrentShell bool) error { |
| 99 | if !runInCurrentShell { |
no test coverage detected