This repository has been archived by the owner on Jun 18, 2022. It is now read-only.
forked from wlan0/rancher-mesos-executor
/
main.go
81 lines (74 loc) · 1.79 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
package main
import (
"os"
"path/filepath"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/mesos/mesos-go/executor"
rancher_mesos "github.com/rancher/rancher-mesos-executor/executor"
"github.com/rancher/rancher-mesos-executor/utils"
)
var (
GITCOMMIT = "HEAD"
)
func main() {
app := cli.NewApp()
app.Name = os.Args[0]
app.Usage = "Start the rancher-mesos executor"
app.Version = GITCOMMIT
app.Author = "Rancher Labs, Inc."
app.Action = start
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "work_dir",
Usage: "working Directory",
EnvVar: "RANCHER_MESOS_WORKDIR",
},
cli.StringFlag{
Name: "bridge_iface",
Usage: "the name of the bridge interface",
EnvVar: "RANCHER_MESOS_BRIDGE",
Value: "br0",
},
cli.StringFlag{
Name: "bridge_cidr",
Usage: "CIDR of the bridge interface",
EnvVar: "RANCHER_MESOS_CIDR",
Value: "192.168.11.0/24",
},
}
app.Run(os.Args)
}
func start(c *cli.Context) {
workDir := c.String("work_dir")
if workDir == "" {
log.Fatal("work_dir is not specified")
}
err := utils.PerformPreChecksAndPrepareHost(workDir)
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Fatal("Environment error, cannot run rancher-mesos-executor")
}
log.Info("Setup of env complete. Starting executor driver")
driver, err := executor.NewMesosExecutorDriver(
executor.DriverConfig{
Executor: rancher_mesos.NewRancherExecutor(
filepath.Join(workDir, "rancheros.iso"),
c.String("bridge_iface"),
c.String("bridge_cidr"),
filepath.Join(workDir, "base-img.img")),
},
)
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Fatal("Error starting executor")
}
_, err = driver.Run()
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Fatal("Error starting executor")
}
}