-
Notifications
You must be signed in to change notification settings - Fork 115
/
provider.go
64 lines (54 loc) · 1.51 KB
/
provider.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
56
57
58
59
60
61
62
63
64
// +build !windows
package jobsupervisor
import (
"time"
"code.cloudfoundry.org/clock"
boshhandler "github.com/cloudfoundry/bosh-agent/handler"
boshmonit "github.com/cloudfoundry/bosh-agent/jobsupervisor/monit"
boshplatform "github.com/cloudfoundry/bosh-agent/platform"
boshdir "github.com/cloudfoundry/bosh-agent/settings/directories"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
)
const jobSupervisorListenPort = 2825
type Provider struct {
supervisors map[string]JobSupervisor
}
func NewProvider(
platform boshplatform.Platform,
client boshmonit.Client,
logger boshlog.Logger,
dirProvider boshdir.Provider,
handler boshhandler.Handler,
) (p Provider) {
timeService := clock.NewClock()
fs := platform.GetFs()
runner := platform.GetRunner()
monitJobSupervisor := NewMonitJobSupervisor(
fs,
runner,
client,
logger,
dirProvider,
jobSupervisorListenPort,
MonitReloadOptions{
MaxTries: 3,
MaxCheckTries: 10,
DelayBetweenCheckTries: 1 * time.Second,
},
timeService,
)
p.supervisors = map[string]JobSupervisor{
"monit": NewWrapperJobSupervisor(monitJobSupervisor, fs, dirProvider, logger),
"dummy": NewDummyJobSupervisor(),
"dummy-nats": NewDummyNatsJobSupervisor(handler),
}
return
}
func (p Provider) Get(name string) (supervisor JobSupervisor, err error) {
supervisor, found := p.supervisors[name]
if !found {
err = bosherr.Errorf("JobSupervisor %s could not be found", name)
}
return
}