-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
89 lines (72 loc) · 1.83 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"flag"
"fmt"
"os"
"github.com/sophron-dev-works/legion/clustering"
"github.com/sophron-dev-works/legion/dbshell"
"github.com/sophron-dev-works/legion/execution"
"github.com/sophron-dev-works/legion/storage"
"github.com/sophron-dev-works/legion/ui"
)
var raftPort, serfPort, httpPort, grpcPort int
var ip, joinNodeID, raftDir string
func init() {
flag.IntVar(&httpPort, "http", 8003, "HTTP Port")
flag.IntVar(&serfPort, "serf", 8001, "Serf Port")
flag.IntVar(&raftPort, "raft", 8002, "Raft Port")
flag.IntVar(&grpcPort, "grpc", 8004, "grpc Port")
flag.StringVar(&ip, "ip", "localhost", "LocalIp")
flag.StringVar(&joinNodeID, "join", "", "id of a node to join")
flag.StringVar(&raftDir, "raftDir", "./raftStorage", "Directory to store Raft Logs")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] \n", os.Args[0])
flag.PrintDefaults()
}
}
func startUI() ui.IrisWrapper {
nc := clustering.NodeConfig{
Ip: ip,
HttpPort: httpPort,
SerfPort: serfPort,
RaftPort: raftPort,
GrpcPort: grpcPort,
RaftDir: raftDir,
Join: joinNodeID,
}
nc.Init()
var node clustering.Node
node.Init(&nc)
go node.Start()
var db storage.SimpleStore
db.Init(&node)
var ee execution.ExecutionEngine
ee.Init(&node)
var ex execution.Executor
ex.Init(&node, &nc, &db)
go ex.Serve()
go ex.Listen()
fmt.Println("done")
iw := ui.Init()
var dash clustering.Dashboard
dash.Init(&node)
var we execution.WorkflowEngine
we.Init(&node, &ex)
var se dbshell.ShellEngine
se.SetNode(db, &node)
var ds dbshell.DistributedShell
go ds.Listen()
ds.Init(db, &node)
iw.AddApp("/dashboard", &dash)
iw.AddApp("/scripts", &ee)
iw.AddApp("/workflows", &we)
iw.AddApp("/shell", &se)
iw.AddApp("/dshell", &ds)
iw.Start(httpPort)
return iw
}
func main() {
flag.Parse()
iw := startUI()
defer iw.Clean()
}