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

Method waitForInstancesToStage

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

Source from the content-addressed store, hash-verified

265}
266
267func (cmd *Start) waitForInstancesToStage(app models.Application) (bool, error) {
268 stagingStartTime := time.Now()
269
270 var err error
271
272 if cmd.StagingTimeout == 0 {
273 app, err = cmd.appRepo.GetApp(app.GUID)
274 } else {
275 for app.PackageState != "STAGED" && app.PackageState != "FAILED" && time.Since(stagingStartTime) < cmd.StagingTimeout {
276 app, err = cmd.appRepo.GetApp(app.GUID)
277 if err != nil {
278 break
279 }
280
281 time.Sleep(cmd.PingerThrottle)
282 }
283 }
284
285 if err != nil {
286 return false, err
287 }
288
289 if app.PackageState == "FAILED" {
290 cmd.ui.Say("")
291 if app.StagingFailedReason == "NoAppDetectedError" {
292 return false, errors.New(T(`{{.Err}}
293TIP: Buildpacks are detected when the "{{.PushCommand}}" is executed from within the directory that contains the app source code.
294
295Use '{{.BuildpackCommand}}' to see a list of supported buildpacks.
296
297Use '{{.Command}}' for more in depth log information.`,
298 map[string]interface{}{
299 "Err": app.StagingFailedReason,
300 "PushCommand": terminal.CommandColor(fmt.Sprintf("%s push", cf.Name)),
301 "BuildpackCommand": terminal.CommandColor(fmt.Sprintf("%s buildpacks", cf.Name)),
302 "Command": terminal.CommandColor(fmt.Sprintf("%s logs %s --recent", cf.Name, app.Name))}))
303 }
304 return false, errors.New(T("{{.Err}}\n\nTIP: use '{{.Command}}' for more information",
305 map[string]interface{}{
306 "Err": app.StagingFailedReason,
307 "Command": terminal.CommandColor(fmt.Sprintf("%s logs %s --recent", cf.Name, app.Name))}))
308 }
309
310 if time.Since(stagingStartTime) >= cmd.StagingTimeout {
311 return false, nil
312 }
313
314 return true, nil
315}
316
317func (cmd *Start) waitForOneRunningInstance(app models.Application) error {
318 timer := time.NewTimer(cmd.StartupTimeout)

Callers 1

WatchStagingMethod · 0.95

Calls 4

CommandColorFunction · 0.92
NowMethod · 0.65
GetAppMethod · 0.65
SayMethod · 0.65

Tested by

no test coverage detected