forked from bobey/gitlab-ci-multi-runner
/
main.go
63 lines (54 loc) · 1.53 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
package main
import (
"os"
"path"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"fmt"
_ "gitlab.com/gitlab-org/gitlab-ci-multi-runner/commands"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/common"
_ "gitlab.com/gitlab-org/gitlab-ci-multi-runner/executors/docker"
_ "gitlab.com/gitlab-org/gitlab-ci-multi-runner/executors/parallels"
_ "gitlab.com/gitlab-org/gitlab-ci-multi-runner/executors/shell"
_ "gitlab.com/gitlab-org/gitlab-ci-multi-runner/executors/ssh"
_ "gitlab.com/gitlab-org/gitlab-ci-multi-runner/shells"
)
func main() {
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Usage = "a GitLab Runner"
app.Version = fmt.Sprintf("%s (%s)", common.VERSION, common.REVISION)
app.Author = "Kamil Trzciński"
app.Email = "ayufan@ayufan.eu"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "debug mode",
EnvVar: "DEBUG",
},
cli.StringFlag{
Name: "log-level, l",
Value: "info",
Usage: "Log level (options: debug, info, warn, error, fatal, panic)",
},
}
// logs
app.Before = func(c *cli.Context) error {
log.SetOutput(os.Stderr)
level, err := log.ParseLevel(c.String("log-level"))
if err != nil {
log.Fatalf(err.Error())
}
log.SetLevel(level)
// If a log level wasn't specified and we are running in debug mode,
// enforce log-level=debug.
if !c.IsSet("log-level") && !c.IsSet("l") && c.Bool("debug") {
log.SetLevel(log.DebugLevel)
}
return nil
}
app.Commands = common.GetCommands()
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}