-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (44 loc) · 1.23 KB
/
main.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
package main
import (
"cube/manager"
"cube/worker"
"fmt"
)
func main() {
// host := os.Getenv("CUBE_HOST")
// port, _ := strconv.Atoi(os.Getenv("5555"))
// mhost := os.Getenv("CUBE_MANAGER_HOST")
// mport, _ := strconv.Atoi(os.Getenv("CUBE_MANAGER_PORT"))
mhost := "localhost"
mport := 5556
whost := "localhost"
wport := 5555
fmt.Println("Starting Cube worker")
w1 := worker.New("worker-1", "persistent")
wapi1 := worker.Api{Address: whost, Port: wport, Worker: w1}
w2 := worker.New("worker-2", "persistent")
wapi2 := worker.Api{Address: whost, Port: wport + 1, Worker: w2}
w3 := worker.New("worker-3", "persistent")
wapi3 := worker.Api{Address: whost, Port: wport + 2, Worker: w3}
go w1.RunTasks()
go w1.UpdateTasks()
go wapi1.Start()
go w2.RunTasks()
go w2.UpdateTasks()
go wapi2.Start()
go w3.RunTasks()
go w3.UpdateTasks()
go wapi3.Start()
fmt.Println("Starting Cube manager")
workers := []string{
fmt.Sprintf("%s:%d", whost, wport),
fmt.Sprintf("%s:%d", whost, wport+1),
fmt.Sprintf("%s:%d", whost, wport+2),
}
m := manager.New(workers, "epvm", "persistent")
mapi := manager.Api{Address: mhost, Port: mport, Manager: m}
go m.ProcessTasks()
go m.UpdateTasks()
go m.DoHealthChecks()
mapi.Start()
}