forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.go
55 lines (43 loc) · 1.02 KB
/
stop.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
46
47
48
49
50
51
52
53
54
55
package action
import (
"errors"
boshjobsuper "github.com/cloudfoundry/bosh-agent/jobsupervisor"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type StopAction struct {
jobSupervisor boshjobsuper.JobSupervisor
}
func NewStop(jobSupervisor boshjobsuper.JobSupervisor) (stop StopAction) {
stop = StopAction{
jobSupervisor: jobSupervisor,
}
return
}
func (a StopAction) IsAsynchronous(_ ProtocolVersion) bool {
return true
}
func (a StopAction) IsPersistent() bool {
return false
}
func (a StopAction) IsLoggable() bool {
return true
}
func (a StopAction) Run(protocolVersion ProtocolVersion) (value string, err error) {
if protocolVersion > 2 {
err = a.jobSupervisor.StopAndWait()
} else {
err = a.jobSupervisor.Stop()
}
if err != nil {
err = bosherr.WrapError(err, "Stopping Monitored Services")
return
}
value = "stopped"
return
}
func (a StopAction) Resume() (interface{}, error) {
return nil, errors.New("not supported")
}
func (a StopAction) Cancel() error {
return errors.New("not supported")
}