main.go 1.73 KB
Newer Older
1
2
3
package main

import (
4
5
6
	"os"
	"path"

7
	"github.com/sirupsen/logrus"
8
	"github.com/urfave/cli"
9

10
11
	"gitlab.com/gitlab-org/gitlab-runner/common"
	"gitlab.com/gitlab-org/gitlab-runner/helpers/cli"
12
	"gitlab.com/gitlab-org/gitlab-runner/log"
13

Tomasz Maczukin's avatar
Tomasz Maczukin committed
14
15
	_ "gitlab.com/gitlab-org/gitlab-runner/cache/gcs"
	_ "gitlab.com/gitlab-org/gitlab-runner/cache/s3"
16
17
18
19
20
21
22
23
24
25
	_ "gitlab.com/gitlab-org/gitlab-runner/commands"
	_ "gitlab.com/gitlab-org/gitlab-runner/commands/helpers"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/docker"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/docker/machine"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/kubernetes"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/parallels"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/shell"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/ssh"
	_ "gitlab.com/gitlab-org/gitlab-runner/executors/virtualbox"
	_ "gitlab.com/gitlab-org/gitlab-runner/shells"
26
27
28
)

func main() {
29
30
31
32
33
34
35
36
37
38
	defer func() {
		if r := recover(); r != nil {
			// log panics forces exit
			if _, ok := r.(*logrus.Entry); ok {
				os.Exit(1)
			}
			panic(r)
		}
	}()

39
40
	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
41
	app.Usage = "a GitLab Runner"
Tomasz Maczukin's avatar
Tomasz Maczukin committed
42
43
	app.Version = common.AppVersion.ShortLine()
	cli.VersionPrinter = common.AppVersion.Printer
44
	app.Authors = []cli.Author{
45
46
47
		{
			Name:  "GitLab Inc.",
			Email: "support@gitlab.com",
48
49
		},
	}
50
	app.Commands = common.GetCommands()
51
	app.CommandNotFound = func(context *cli.Context, command string) {
52
		logrus.Fatalln("Command", command, "not found.")
53
	}
54

55
	cli_helpers.InitCli()
56
57
58
	cli_helpers.LogRuntimePlatform(app)
	cli_helpers.SetupCPUProfile(app)
	cli_helpers.FixHOME(app)
59
	cli_helpers.WarnOnBool(os.Args)
60

61
62
	log.ConfigureLogging(app)

63
	if err := app.Run(os.Args); err != nil {
64
		logrus.Fatal(err)
65
	}
66
}