forked from marmelab/gaudi
/
main.go
50 lines (40 loc) · 940 Bytes
/
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
package main
import (
"flag"
"github.com/marmelab/gaudi/maestro"
"github.com/marmelab/gaudi/util"
"os"
)
var (
config = flag.String("config", ".gaudi.yml", "File describing the architecture")
stop = flag.Bool("stop", false, "Stop all applications ( data not stored in volumes will be lost)")
check = flag.Bool("check", false, "Check if all applications are running")
)
func main() {
flag.Parse()
m := maestro.Maestro{}
m.InitFromFile(retrieveConfigPath(*config))
if *check {
m.Check()
} else if *stop {
m.Stop()
} else {
m.Start()
}
}
func retrieveConfigPath(configFile string) string {
if len(configFile) == 0 {
panic("Config file name cannot be empty.")
}
if string(configFile[0]) != "/" {
currentDir, err := os.Getwd()
if err != nil {
panic(err)
}
configFile = currentDir + "/" + configFile
}
if !util.IsFile(configFile) {
panic("Config file must be a file.")
}
return configFile
}