ability to provide Docker URL endpoints
This commit is contained in:
parent
34698d9aed
commit
55d9dbedcb
3 changed files with 43 additions and 9 deletions
12
README.md
12
README.md
|
@ -60,6 +60,13 @@ port=""
|
|||
from=""
|
||||
user=""
|
||||
pass=""
|
||||
|
||||
[worker]
|
||||
nodes=[
|
||||
"unix:///var/run/docker.sock",
|
||||
"unix:///var/run/docker.sock"
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
Or you can use environment variables
|
||||
|
@ -93,6 +100,11 @@ export DRONE_SMTP_PORT=""
|
|||
export DRONE_SMTP_FROM=""
|
||||
export DRONE_SMTP_USER=""
|
||||
export DRONE_SMTP_PASS=""
|
||||
|
||||
# worker nodes
|
||||
# these are optional. If not specified Drone will add
|
||||
# two worker nodes that connect to $DOCKER_HOST
|
||||
export DRONE_WORKER_NODES="tcp://0.0.0.0:2375,tcp://0.0.0.0:2375"
|
||||
```
|
||||
|
||||
Or a combination of the two:
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"database/sql"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -55,6 +56,8 @@ var (
|
|||
prefix string
|
||||
|
||||
open bool
|
||||
|
||||
nodes StringArr
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -70,9 +73,12 @@ func main() {
|
|||
flag.IntVar(&workers, "workers", runtime.NumCPU(), "")
|
||||
flag.Parse()
|
||||
|
||||
config.Var(&nodes, "worker-nodes")
|
||||
config.BoolVar(&open, "registration-open", false)
|
||||
config.SetPrefix(prefix)
|
||||
config.Parse(conf)
|
||||
if err := config.Parse(conf); err != nil {
|
||||
fmt.Println("Error parsing config", err)
|
||||
}
|
||||
|
||||
// setup the remote services
|
||||
bitbucket.Register()
|
||||
|
@ -102,14 +108,16 @@ func main() {
|
|||
workerc := make(chan chan *model.Request)
|
||||
worker.NewDispatch(queue, workerc).Start()
|
||||
|
||||
// there must be a minimum of 1 worker
|
||||
if workers <= 0 {
|
||||
workers = 1
|
||||
}
|
||||
|
||||
// create the specified number of worker nodes
|
||||
for i := 0; i < workers; i++ {
|
||||
// if no worker nodes are specified than start 2 workers
|
||||
// using the default DOCKER_HOST
|
||||
if nodes == nil || len(nodes) == 0 {
|
||||
worker.NewWorker(workerc, users, repos, commits, pubsub, &model.Server{}).Start()
|
||||
worker.NewWorker(workerc, users, repos, commits, pubsub, &model.Server{}).Start()
|
||||
} else {
|
||||
for _, node := range nodes {
|
||||
println(node)
|
||||
worker.NewWorker(workerc, users, repos, commits, pubsub, &model.Server{Host: node}).Start()
|
||||
}
|
||||
}
|
||||
|
||||
// setup the session managers
|
||||
|
@ -162,3 +170,17 @@ func main() {
|
|||
panic(http.ListenAndServe(port, nil))
|
||||
}
|
||||
}
|
||||
|
||||
type StringArr []string
|
||||
|
||||
func (s *StringArr) String() string {
|
||||
return fmt.Sprint(*s)
|
||||
}
|
||||
|
||||
func (s *StringArr) Set(value string) error {
|
||||
for _, str := range strings.Split(value, ",") {
|
||||
str = strings.TrimSpace(str)
|
||||
*s = append(*s, str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue