(app models.Application, orgName, spaceName string, start func(app models.Application) (models.Application, error))
| 155 | } |
| 156 | |
| 157 | func (cmd *Start) WatchStaging(app models.Application, orgName, spaceName string, start func(app models.Application) (models.Application, error)) (models.Application, error) { |
| 158 | stopChan := make(chan bool, 1) |
| 159 | |
| 160 | loggingDoneWait := new(sync.WaitGroup) |
| 161 | loggingDoneWait.Add(1) |
| 162 | |
| 163 | go cmd.TailStagingLogs(app, stopChan, loggingDoneWait) |
| 164 | |
| 165 | updatedApp, err := start(app) |
| 166 | if err != nil { |
| 167 | return models.Application{}, err |
| 168 | } |
| 169 | |
| 170 | isStaged, err := cmd.waitForInstancesToStage(updatedApp) |
| 171 | if err != nil { |
| 172 | return models.Application{}, err |
| 173 | } |
| 174 | |
| 175 | stopChan <- true |
| 176 | |
| 177 | loggingDoneWait.Wait() |
| 178 | |
| 179 | cmd.ui.Say("") |
| 180 | |
| 181 | if !isStaged { |
| 182 | return models.Application{}, fmt.Errorf("%s failed to stage within %f minutes", app.Name, cmd.StagingTimeout.Minutes()) |
| 183 | } |
| 184 | |
| 185 | if app.InstanceCount > 0 { |
| 186 | err = cmd.waitForOneRunningInstance(updatedApp) |
| 187 | if err != nil { |
| 188 | return models.Application{}, err |
| 189 | } |
| 190 | cmd.ui.Say(terminal.HeaderColor(T("\nApp started\n"))) |
| 191 | cmd.ui.Say("") |
| 192 | } else { |
| 193 | cmd.ui.Say(terminal.HeaderColor(T("\nApp state changed to started, but note that it has 0 instances.\n"))) |
| 194 | cmd.ui.Say("") |
| 195 | } |
| 196 | cmd.ui.Ok() |
| 197 | |
| 198 | // detectedstartcommand on first push is not present until starting completes |
| 199 | startedApp, err := cmd.appRepo.GetApp(updatedApp.GUID) |
| 200 | if err != nil { |
| 201 | return models.Application{}, err |
| 202 | } |
| 203 | |
| 204 | var appStartCommand string |
| 205 | if app.Command == "" { |
| 206 | appStartCommand = startedApp.DetectedStartCommand |
| 207 | } else { |
| 208 | appStartCommand = startedApp.Command |
| 209 | } |
| 210 | |
| 211 | cmd.ui.Say(T("\nApp {{.AppName}} was started using this command `{{.Command}}`\n", |
| 212 | map[string]interface{}{ |
| 213 | "AppName": terminal.EntityNameColor(startedApp.Name), |
| 214 | "Command": appStartCommand, |
no test coverage detected