コード例 #1
0
ファイル: drone.go プロジェクト: fclairamb/drone
func main() {
	flag.Parse()

	// debug level if requested by user
	if *debug {
		logrus.SetLevel(logrus.DebugLevel)
	}

	// Load the configuration from env file
	env := envconfig.Load(*dotenv)

	// Setup the database driver
	store_ := datastore.Load(env)

	// setup the remote driver
	remote_ := remote.Load(env)

	// setup the runner
	engine_ := engine.Load(env, store_)

	// setup the server and start the listener
	server_ := server.Load(env)
	server_.Run(
		router.Load(
			header.Version(build),
			cache.Default(),
			context.SetStore(store_),
			context.SetRemote(remote_),
			context.SetEngine(engine_),
		),
	)
}
コード例 #2
0
ファイル: server.go プロジェクト: Ablu/drone
func server(c *cli.Context) error {

	if c.Bool("agreement.ack") == false || c.Bool("agreement.fix") == false {
		fmt.Println(agreement)
		os.Exit(1)
	}

	// debug level if requested by user
	if c.Bool("debug") {
		logrus.SetLevel(logrus.DebugLevel)
	} else {
		logrus.SetLevel(logrus.WarnLevel)
	}

	// setup the server and start the listener
	handler := router.Load(
		ginrus.Ginrus(logrus.StandardLogger(), time.RFC3339, true),
		middleware.Version,
		middleware.Config(c),
		middleware.Queue(c),
		middleware.Stream(c),
		middleware.Bus(c),
		middleware.Cache(c),
		middleware.Store(c),
		middleware.Remote(c),
		middleware.Agents(c),
	)

	// start the server with tls enabled
	if c.String("server-cert") != "" {
		return http.ListenAndServeTLS(
			c.String("server-addr"),
			c.String("server-cert"),
			c.String("server-key"),
			handler,
		)
	}

	// start the server without tls enabled
	return http.ListenAndServe(
		c.String("server-addr"),
		handler,
	)
}