MCPcopy Index your code
hub / github.com/ddev/ddev / WaitForServices

Method WaitForServices

pkg/ddevapp/ddevapp.go:3009–3031  ·  view source on GitHub ↗

WaitForServices waits for all the services in docker-compose to come up

()

Source from the content-addressed store, hash-verified

3007
3008// WaitForServices waits for all the services in docker-compose to come up
3009func (app *DdevApp) WaitForServices() error {
3010 var requiredContainers []string
3011 if app.ComposeYaml != nil && app.ComposeYaml.Services != nil {
3012 for k := range app.ComposeYaml.Services {
3013 requiredContainers = append(requiredContainers, k)
3014 }
3015 } else {
3016 util.Failed("unable to get required startup services to wait for")
3017 }
3018 wait := output.StartWait(fmt.Sprintf("Waiting for these services to become ready: %v", requiredContainers))
3019
3020 labels := map[string]string{
3021 "com.ddev.site-name": app.GetName(),
3022 "com.docker.compose.oneoff": "False",
3023 }
3024 waitTime := app.GetMaxContainerWaitTime()
3025 _, err := dockerutil.ContainerWait(waitTime, labels)
3026 elapsed := wait.Complete(err)
3027 if err != nil {
3028 return fmt.Errorf("timed out waiting for containers (%v) to start after %.1fs: err=%v", requiredContainers, elapsed.Seconds(), err)
3029 }
3030 return nil
3031}
3032
3033// Wait ensures that the app service containers are healthy.
3034func (app *DdevApp) Wait(requiredContainers []string) error {

Callers

nothing calls this directly

Calls 7

GetNameMethod · 0.95
FailedFunction · 0.92
StartWaitFunction · 0.92
ContainerWaitFunction · 0.92
CompleteMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected