main.go 987 Bytes
Newer Older
1 2 3 4 5 6
package main

import (
	"os"
	"path"

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

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

13
	_ "gitlab.com/gitlab-org/gitlab-runner/commands/helpers"
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
)

func main() {
	defer func() {
		if r := recover(); r != nil {
			// log panics forces exit
			if _, ok := r.(*logrus.Entry); ok {
				os.Exit(1)
			}
			panic(r)
		}
	}()

	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Usage = "a GitLab Runner Helper"
Tomasz Maczukin's avatar
Tomasz Maczukin committed
30 31
	app.Version = common.AppVersion.ShortLine()
	cli.VersionPrinter = common.AppVersion.Printer
32
	app.Authors = []cli.Author{
33 34 35
		{
			Name:  "GitLab Inc.",
			Email: "[email protected]",
36 37 38 39
		},
	}
	app.Commands = common.GetCommands()
	app.CommandNotFound = func(context *cli.Context, command string) {
40
		logrus.Fatalln("Command", command, "not found")
41 42
	}

43 44
	log.AddSecretsCleanupLogHook()
	log.ConfigureLogging(app)
45

46 47 48 49
	if err := app.Run(os.Args); err != nil {
		logrus.Fatal(err)
	}
}