2015-09-30 03:21:17 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"github.com/drone/drone/engine"
|
|
|
|
"github.com/drone/drone/remote"
|
|
|
|
"github.com/drone/drone/router"
|
2015-10-21 01:45:24 +02:00
|
|
|
"github.com/drone/drone/router/middleware/cache"
|
2015-09-30 03:21:17 +02:00
|
|
|
"github.com/drone/drone/router/middleware/context"
|
2015-10-13 11:08:08 +02:00
|
|
|
"github.com/drone/drone/router/middleware/header"
|
2015-09-30 03:21:17 +02:00
|
|
|
"github.com/drone/drone/shared/envconfig"
|
|
|
|
"github.com/drone/drone/shared/server"
|
2015-10-22 01:14:02 +02:00
|
|
|
"github.com/drone/drone/store/datastore"
|
2015-09-30 03:21:17 +02:00
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
dotenv = flag.String("config", ".env", "")
|
2015-09-30 21:37:32 +02:00
|
|
|
debug = flag.Bool("debug", false, "")
|
2015-09-30 03:21:17 +02: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
|
2015-10-22 01:14:02 +02:00
|
|
|
store_ := datastore.Load(env)
|
2015-09-30 03:21:17 +02:00
|
|
|
|
|
|
|
// setup the remote driver
|
|
|
|
remote_ := remote.Load(env)
|
|
|
|
|
|
|
|
// setup the runner
|
2015-10-22 01:14:02 +02:00
|
|
|
engine_ := engine.Load(env, store_)
|
2015-09-30 03:21:17 +02:00
|
|
|
|
|
|
|
// setup the server and start the listener
|
|
|
|
server_ := server.Load(env)
|
|
|
|
server_.Run(
|
|
|
|
router.Load(
|
2016-03-30 09:48:47 +02:00
|
|
|
header.Version,
|
2015-10-21 01:45:24 +02:00
|
|
|
cache.Default(),
|
2015-10-22 01:14:02 +02:00
|
|
|
context.SetStore(store_),
|
2015-09-30 03:21:17 +02:00
|
|
|
context.SetRemote(remote_),
|
|
|
|
context.SetEngine(engine_),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|