2015-09-30 01:21:17 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"github.com/drone/drone/engine"
|
|
|
|
"github.com/drone/drone/remote"
|
|
|
|
"github.com/drone/drone/router"
|
|
|
|
"github.com/drone/drone/router/middleware/context"
|
2015-10-13 09:08:08 +00:00
|
|
|
"github.com/drone/drone/router/middleware/header"
|
2015-09-30 01:21:17 +00:00
|
|
|
"github.com/drone/drone/shared/database"
|
|
|
|
"github.com/drone/drone/shared/envconfig"
|
|
|
|
"github.com/drone/drone/shared/server"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2015-10-13 09:08:08 +00:00
|
|
|
// build revision number populated by the continuous
|
|
|
|
// integration server at compile time.
|
|
|
|
var build string = "custom"
|
|
|
|
|
2015-09-30 01:21:17 +00:00
|
|
|
var (
|
|
|
|
dotenv = flag.String("config", ".env", "")
|
2015-09-30 19:37:32 +00:00
|
|
|
debug = flag.Bool("debug", false, "")
|
2015-09-30 01:21:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
database_ := database.Load(env)
|
|
|
|
|
|
|
|
// setup the remote driver
|
|
|
|
remote_ := remote.Load(env)
|
|
|
|
|
|
|
|
// setup the runner
|
2015-10-06 22:50:15 +00:00
|
|
|
engine_ := engine.Load(database_, env, remote_)
|
2015-09-30 01:21:17 +00:00
|
|
|
|
|
|
|
// setup the server and start the listener
|
|
|
|
server_ := server.Load(env)
|
|
|
|
server_.Run(
|
|
|
|
router.Load(
|
2015-10-13 09:08:08 +00:00
|
|
|
header.Version(build),
|
2015-09-30 01:21:17 +00:00
|
|
|
context.SetDatabase(database_),
|
|
|
|
context.SetRemote(remote_),
|
|
|
|
context.SetEngine(engine_),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|