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

Method RestartServices

internal/devbox/services.go:136–173  ·  view source on GitHub ↗
(
	ctx context.Context, runInCurrentShell bool, serviceNames ...string,
)

Source from the content-addressed store, hash-verified

134}
135
136func (d *Devbox) RestartServices(
137 ctx context.Context, runInCurrentShell bool, serviceNames ...string,
138) error {
139 if !runInCurrentShell {
140 return d.runDevboxServicesScript(ctx,
141 append(
142 []string{"restart", "--run-in-current-shell"},
143 serviceNames...,
144 ),
145 )
146 }
147
148 if !services.ProcessManagerIsRunning(d.projectDir) {
149 fmt.Fprintln(d.stderr, "Process-compose is not running. Starting it now...")
150 fmt.Fprintln(d.stderr, "\nTip: We recommend using `devbox services up` to start process-compose and your services")
151 return d.StartProcessManager(ctx, runInCurrentShell, serviceNames, devopt.ProcessComposeOpts{Background: true})
152 }
153
154 // TODO: Restart with no services should restart the _currently running_ services. This means we should get the list of running services from the process-compose, then restart them all.
155
156 svcSet, err := d.Services()
157 if err != nil {
158 return err
159 }
160
161 for _, s := range serviceNames {
162 if _, ok := svcSet[s]; !ok {
163 return usererr.New("Service %s not found in your project", s)
164 }
165 err := services.RestartServices(ctx, s, d.projectDir, d.stderr)
166 if err != nil {
167 fmt.Printf("Error restarting service %s: %s", s, err)
168 } else {
169 fmt.Printf("Service %s restarted", s)
170 }
171 }
172 return nil
173}
174
175func (d *Devbox) AttachToProcessManager(ctx context.Context) error {
176 if !services.ProcessManagerIsRunning(d.projectDir) {

Callers 1

restartServicesFunction · 0.80

Calls 6

StartProcessManagerMethod · 0.95
ServicesMethod · 0.95
ProcessManagerIsRunningFunction · 0.92
NewFunction · 0.92
RestartServicesFunction · 0.92

Tested by

no test coverage detected