( ctx context.Context, runInCurrentShell bool, serviceNames ...string, )
| 13 | ) |
| 14 | |
| 15 | func (d *Devbox) StartServices( |
| 16 | ctx context.Context, runInCurrentShell bool, serviceNames ...string, |
| 17 | ) error { |
| 18 | if !runInCurrentShell { |
| 19 | return d.runDevboxServicesScript(ctx, |
| 20 | append( |
| 21 | []string{"start", "--run-in-current-shell"}, |
| 22 | serviceNames..., |
| 23 | ), |
| 24 | ) |
| 25 | } |
| 26 | |
| 27 | if !services.ProcessManagerIsRunning(d.projectDir) { |
| 28 | fmt.Fprintln(d.stderr, "Process-compose is not running. Starting it now...") |
| 29 | fmt.Fprintln(d.stderr, "\nNOTE: We recommend using `devbox services up` to start process-compose and your services") |
| 30 | return d.StartProcessManager(ctx, runInCurrentShell, serviceNames, devopt.ProcessComposeOpts{Background: true}) |
| 31 | } |
| 32 | |
| 33 | svcSet, err := d.Services() |
| 34 | if err != nil { |
| 35 | return err |
| 36 | } |
| 37 | |
| 38 | if len(svcSet) == 0 { |
| 39 | return usererr.New("No services found in your project") |
| 40 | } |
| 41 | |
| 42 | for _, s := range serviceNames { |
| 43 | if _, ok := svcSet[s]; !ok { |
| 44 | return usererr.New("Service %s not found in your project", s) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | for _, s := range serviceNames { |
| 49 | err := services.StartServices(ctx, d.stderr, s, d.projectDir) |
| 50 | if err != nil { |
| 51 | fmt.Fprintf(d.stderr, "Error starting service %s: %s", s, err) |
| 52 | } else { |
| 53 | fmt.Fprintf(d.stderr, "Service %s started successfully", s) |
| 54 | } |
| 55 | } |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func (d *Devbox) StopServices(ctx context.Context, runInCurrentShell, allProjects bool, serviceNames ...string) error { |
| 60 | if !runInCurrentShell { |
no test coverage detected