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

Method GetMaxContainerWaitTime

pkg/ddevapp/ddevapp.go:2278–2322  ·  view source on GitHub ↗

GetMaxContainerWaitTime looks through all services and returns the max time we expect to wait for all containers to become `healthy`. Mostly this is healthcheck.start_period. Defaults to DefaultContainerTimeout (usually 120 unless overridden)

()

Source from the content-addressed store, hash-verified

2276// to wait for all containers to become `healthy`. Mostly this is healthcheck.start_period.
2277// Defaults to DefaultContainerTimeout (usually 120 unless overridden)
2278func (app *DdevApp) GetMaxContainerWaitTime() int {
2279 defaultContainerTimeout, _ := strconv.Atoi(app.DefaultContainerTimeout)
2280 maxWaitTime := defaultContainerTimeout
2281
2282 if app.ComposeYaml == nil || app.ComposeYaml.Services == nil {
2283 return defaultContainerTimeout
2284 }
2285 for _, service := range app.ComposeYaml.Services {
2286 if service.HealthCheck == nil {
2287 continue
2288 }
2289 if service.HealthCheck.StartPeriod != nil {
2290 duration, err := time.ParseDuration(service.HealthCheck.StartPeriod.String())
2291 if err != nil {
2292 continue
2293 }
2294 t := int(duration.Seconds())
2295 if t > maxWaitTime {
2296 maxWaitTime = t
2297 }
2298 continue
2299 }
2300 // In this case we didn't have a specified start_period, so guess at one
2301 // Use defaults for interval and retries
2302 // https://docs.docker.com/reference/dockerfile/#healthcheck
2303 interval := 5
2304 retries := 3
2305
2306 if service.HealthCheck.Interval != nil {
2307 intervalInt, err := time.ParseDuration(service.HealthCheck.Interval.String())
2308 if err == nil {
2309 interval = int(intervalInt.Seconds())
2310 }
2311 }
2312 if service.HealthCheck.Retries != nil {
2313 retries = int(*service.HealthCheck.Retries)
2314 }
2315 // If the retries*interval is greater than what we've found before
2316 // then use it. This will be unusual.
2317 if retries*interval > maxWaitTime {
2318 maxWaitTime = retries * interval
2319 }
2320 }
2321 return maxWaitTime
2322}
2323
2324// CheckExistingAppInApproot looks to see if we already have a project in this approot with different name
2325func (app *DdevApp) CheckExistingAppInApproot() error {

Callers 7

RestoreSnapshotMethod · 0.95
RenderComposeYAMLMethod · 0.95
WaitForServicesMethod · 0.95
WaitMethod · 0.95
WaitByLabelsMethod · 0.95
WriteBuildDockerfileFunction · 0.80

Calls

no outgoing calls

Tested by 1