-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnomad-box.go
53 lines (41 loc) · 828 Bytes
/
nomad-box.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
package main
import (
"fmt"
"os"
"os/signal"
"github.com/mmcquillan/nomad-box/checks"
"github.com/mmcquillan/nomad-box/config"
"github.com/mmcquillan/nomad-box/node"
"github.com/mmcquillan/nomad-box/run"
)
func main() {
// configurable variables
cfg := config.MakeConfig()
checks.Checks(&cfg)
// make nodes
nodes := node.MakeNodes(cfg)
// clean
if cfg.Clean {
node.CleanNodeResources(cfg, nodes)
os.Exit(0)
}
// plan exit
if cfg.Plan {
run.Out("Plan Mode (quitting)")
os.Exit(0)
}
// start up nodes
node.BuildNodes(cfg, nodes)
// setup to catch sigint
q := make(chan os.Signal, 1)
signal.Notify(q, os.Interrupt)
go func() {
<-q
node.CleanNodes(cfg, nodes)
}()
// wait to quit
run.Out("Cluster Running (enter to quit)")
fmt.Scanln()
// clean up
node.CleanNodes(cfg, nodes)
}