mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-11 17:18:09 +02:00
ability to provide Docker URL endpoints
This commit is contained in:
parent
34698d9aed
commit
55d9dbedcb
12
README.md
12
README.md
@ -60,6 +60,13 @@ port=""
|
|||||||
from=""
|
from=""
|
||||||
user=""
|
user=""
|
||||||
pass=""
|
pass=""
|
||||||
|
|
||||||
|
[worker]
|
||||||
|
nodes=[
|
||||||
|
"unix:///var/run/docker.sock",
|
||||||
|
"unix:///var/run/docker.sock"
|
||||||
|
]
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can use environment variables
|
Or you can use environment variables
|
||||||
@ -93,6 +100,11 @@ export DRONE_SMTP_PORT=""
|
|||||||
export DRONE_SMTP_FROM=""
|
export DRONE_SMTP_FROM=""
|
||||||
export DRONE_SMTP_USER=""
|
export DRONE_SMTP_USER=""
|
||||||
export DRONE_SMTP_PASS=""
|
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:
|
Or a combination of the two:
|
||||||
|
File diff suppressed because one or more lines are too long
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -55,6 +56,8 @@ var (
|
|||||||
prefix string
|
prefix string
|
||||||
|
|
||||||
open bool
|
open bool
|
||||||
|
|
||||||
|
nodes StringArr
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -70,9 +73,12 @@ func main() {
|
|||||||
flag.IntVar(&workers, "workers", runtime.NumCPU(), "")
|
flag.IntVar(&workers, "workers", runtime.NumCPU(), "")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
config.Var(&nodes, "worker-nodes")
|
||||||
config.BoolVar(&open, "registration-open", false)
|
config.BoolVar(&open, "registration-open", false)
|
||||||
config.SetPrefix(prefix)
|
config.SetPrefix(prefix)
|
||||||
config.Parse(conf)
|
if err := config.Parse(conf); err != nil {
|
||||||
|
fmt.Println("Error parsing config", err)
|
||||||
|
}
|
||||||
|
|
||||||
// setup the remote services
|
// setup the remote services
|
||||||
bitbucket.Register()
|
bitbucket.Register()
|
||||||
@ -102,14 +108,16 @@ func main() {
|
|||||||
workerc := make(chan chan *model.Request)
|
workerc := make(chan chan *model.Request)
|
||||||
worker.NewDispatch(queue, workerc).Start()
|
worker.NewDispatch(queue, workerc).Start()
|
||||||
|
|
||||||
// there must be a minimum of 1 worker
|
// if no worker nodes are specified than start 2 workers
|
||||||
if workers <= 0 {
|
// using the default DOCKER_HOST
|
||||||
workers = 1
|
if nodes == nil || len(nodes) == 0 {
|
||||||
}
|
|
||||||
|
|
||||||
// create the specified number of worker nodes
|
|
||||||
for i := 0; i < workers; i++ {
|
|
||||||
worker.NewWorker(workerc, users, repos, commits, pubsub, &model.Server{}).Start()
|
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
|
// setup the session managers
|
||||||
@ -162,3 +170,17 @@ func main() {
|
|||||||
panic(http.ListenAndServe(port, nil))
|
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 New Issue
Block a user