MCPcopy Index your code
hub / github.com/jetify-com/devbox / ListServices

Method ListServices

internal/devbox/services.go:98–134  ·  view source on GitHub ↗
(ctx context.Context, runInCurrentShell bool)

Source from the content-addressed store, hash-verified

96}
97
98func (d *Devbox) ListServices(ctx context.Context, runInCurrentShell bool) error {
99 if !runInCurrentShell {
100 return d.runDevboxServicesScript(ctx, []string{"ls", "--run-in-current-shell"})
101 }
102
103 svcSet, err := d.Services()
104 if err != nil {
105 return err
106 }
107
108 if len(svcSet) == 0 {
109 fmt.Fprintln(d.stderr, "No services found in your project")
110 return nil
111 }
112
113 if !services.ProcessManagerIsRunning(d.projectDir) {
114 fmt.Fprintln(d.stderr, "No services currently running. Run `devbox services up` to start them:")
115 fmt.Fprintln(d.stderr, "")
116 for _, s := range svcSet {
117 fmt.Fprintf(d.stderr, " %s\n", s.Name)
118 }
119 return nil
120 }
121 tw := tabwriter.NewWriter(d.stderr, 3, 2, 8, ' ', tabwriter.TabIndent)
122 pcSvcs, err := services.ListServices(ctx, d.projectDir, d.stderr)
123 if err != nil {
124 fmt.Fprintln(d.stderr, "Error listing services: ", err)
125 } else {
126 fmt.Fprintln(d.stderr, "Services running in process-compose:")
127 fmt.Fprintln(tw, "PID\tNAME\tNAMESPACE\tSTATUS\tAGE\tHEALTH\tRESTARTS\tEXIT CODE")
128 for _, s := range pcSvcs {
129 fmt.Fprintf(tw, "%d\t%s\t%s\t%s\t%s\t%s\t%d\t%d\n", s.PID, s.Name, s.Namespace, s.Status, s.Age, s.Health, s.Restarts, s.ExitCode)
130 }
131 tw.Flush()
132 }
133 return nil
134}
135
136func (d *Devbox) RestartServices(
137 ctx context.Context, runInCurrentShell bool, serviceNames ...string,

Callers 1

listServicesFunction · 0.80

Calls 4

ServicesMethod · 0.95
ProcessManagerIsRunningFunction · 0.92
ListServicesFunction · 0.92

Tested by

no test coverage detected