forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider_windows.go
76 lines (65 loc) · 1.88 KB
/
provider_windows.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
65
66
67
68
69
70
71
72
73
74
75
76
// +build windows
package jobsupervisor
import (
"os"
"time"
"github.com/pivotal-golang/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) {
fs := platform.GetFs()
runner := platform.GetRunner()
timeService := clock.NewClock()
monitJobSupervisor := NewMonitJobSupervisor(
fs,
runner,
client,
logger,
dirProvider,
jobSupervisorListenPort,
MonitReloadOptions{
MaxTries: 3,
MaxCheckTries: 6,
DelayBetweenCheckTries: 5 * time.Second,
},
timeService,
)
network, err := platform.GetDefaultNetwork()
var machineIP string
if err != nil {
machineIP, _ = os.Hostname()
logger.Debug("providerWindows", "Initializing jobsupervisor.provider_windows: %s, using hostname \"%s\"instead of IP", err, machineIP)
} else {
machineIP = network.IP
}
p.supervisors = map[string]JobSupervisor{
"monit": monitJobSupervisor,
"dummy": NewDummyJobSupervisor(),
"dummy-nats": NewDummyNatsJobSupervisor(handler),
"windows": NewWindowsJobSupervisor(runner, dirProvider, fs, logger, jobSupervisorListenPort,
make(chan bool), machineIP),
}
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
}