-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor_application.go
45 lines (35 loc) · 1.02 KB
/
monitor_application.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package broker
import (
"time"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
"code.cloudfoundry.org/lager"
"github.com/cloudfoundry-community/go-cfclient"
)
func (broker *SCSBroker) MonitorApplicationStartup(cfClient *ccv3.Client, community *cfclient.Client, logger lager.Logger, appGUID string) (bool, error) {
waittime := 30
timepassed := 0
for timepassed < waittime {
time.Sleep(time.Second)
timepassed += 1
successStart, err := broker.checkApplicationStatus(cfClient, community, logger, appGUID)
if err != nil {
return false, err
}
if !successStart {
return successStart, err
}
}
return true, nil
}
func (broker *SCSBroker) checkApplicationStatus(cfClient *ccv3.Client, community *cfclient.Client, logger lager.Logger, appGUID string) (bool, error) {
stats, err := getProcessStatsByAppAndType(cfClient, community, broker.Logger, appGUID, "web")
if err != nil {
return false, err
}
for _, stat := range stats {
if stat.State == "CRASHED" {
return false, err
}
}
return true, nil
}