WaitForServices waits for all the services in docker-compose to come up
()
| 3007 | |
| 3008 | // WaitForServices waits for all the services in docker-compose to come up |
| 3009 | func (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. |
| 3034 | func (app *DdevApp) Wait(requiredContainers []string) error { |
nothing calls this directly
no test coverage detected