MCPcopy Index your code
hub / github.com/cloudfoundry/cli / waitForOneRunningInstance

Method waitForOneRunningInstance

cf/commands/application/start.go:317–350  ·  view source on GitHub ↗
(app models.Application)

Source from the content-addressed store, hash-verified

315}
316
317func (cmd *Start) waitForOneRunningInstance(app models.Application) error {
318 timer := time.NewTimer(cmd.StartupTimeout)
319
320 for {
321 select {
322 case <-timer.C:
323 tipMsg := T("Start app timeout\n\nTIP: Application must be listening on the right port. Instead of hard coding the port, use the $PORT environment variable.") + "\n\n"
324 tipMsg += T("Use '{{.Command}}' for more information", map[string]interface{}{"Command": terminal.CommandColor(fmt.Sprintf("%s logs %s --recent", cf.Name, app.Name))})
325
326 return errors.New(tipMsg)
327
328 default:
329 count, err := cmd.fetchInstanceCount(app.GUID)
330 if err != nil {
331 cmd.ui.Warn("Could not fetch instance count: %s", err.Error())
332 time.Sleep(cmd.PingerThrottle)
333 continue
334 }
335
336 cmd.ui.Say(instancesDetails(count))
337
338 if count.running > 0 {
339 return nil
340 }
341
342 if count.flapping > 0 || count.crashed > 0 {
343 return errors.New(T("Start unsuccessful\n\nTIP: use '{{.Command}}' for more information",
344 map[string]interface{}{"Command": terminal.CommandColor(fmt.Sprintf("%s logs %s --recent", cf.Name, app.Name))}))
345 }
346
347 time.Sleep(cmd.PingerThrottle)
348 }
349 }
350}
351
352type instanceCount struct {
353 running int

Callers 1

WatchStagingMethod · 0.95

Calls 6

fetchInstanceCountMethod · 0.95
CommandColorFunction · 0.92
instancesDetailsFunction · 0.85
WarnMethod · 0.65
ErrorMethod · 0.65
SayMethod · 0.65

Tested by

no test coverage detected