(app models.Application)
| 315 | } |
| 316 | |
| 317 | func (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 | |
| 352 | type instanceCount struct { |
| 353 | running int |
no test coverage detected