forked from moby/moby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a "daemon" build tag and toggle it with the already-existing "DOC…
…KER_CLIENTONLY" build variable This works mostly by refactoring our "main" package to be careful about what it imports based on the daemon build tag. :) Also, I've updated Travis to test "client-only" compilation after it tests the daemon version. Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
- Loading branch information
Showing
6 changed files
with
247 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// +build !daemon | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
) | ||
|
||
const CanDaemon = false | ||
|
||
func mainSysinit() { | ||
log.Fatal("This is a client-only binary - running it as 'dockerinit' is not supported.") | ||
} | ||
|
||
func mainDaemon() { | ||
log.Fatal("This is a client-only binary - running the Docker daemon is not supported.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// +build daemon | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
"net" | ||
|
||
"github.com/docker/docker/builtins" | ||
"github.com/docker/docker/dockerversion" | ||
"github.com/docker/docker/engine" | ||
flag "github.com/docker/docker/pkg/mflag" | ||
"github.com/docker/docker/sysinit" | ||
) | ||
|
||
const CanDaemon = true | ||
|
||
func mainSysinit() { | ||
// Running in init mode | ||
sysinit.SysInit() | ||
} | ||
|
||
func mainDaemon() { | ||
if flag.NArg() != 0 { | ||
flag.Usage() | ||
return | ||
} | ||
|
||
if *bridgeName != "" && *bridgeIp != "" { | ||
log.Fatal("You specified -b & --bip, mutually exclusive options. Please specify only one.") | ||
} | ||
|
||
if !*flEnableIptables && !*flInterContainerComm { | ||
log.Fatal("You specified --iptables=false with --icc=false. ICC uses iptables to function. Please set --icc or --iptables to true.") | ||
} | ||
|
||
if net.ParseIP(*flDefaultIp) == nil { | ||
log.Fatalf("Specified --ip=%s is not in correct format \"0.0.0.0\".", *flDefaultIp) | ||
} | ||
|
||
eng := engine.New() | ||
// Load builtins | ||
if err := builtins.Register(eng); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// handle the pidfile early. https://github.com/docker/docker/issues/6973 | ||
if len(*pidfile) > 0 { | ||
job := eng.Job("initserverpidfile", *pidfile) | ||
if err := job.Run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
// load the daemon in the background so we can immediately start | ||
// the http api so that connections don't fail while the daemon | ||
// is booting | ||
go func() { | ||
// Load plugin: httpapi | ||
job := eng.Job("initserver") | ||
// include the variable here too, for the server config | ||
job.Setenv("Pidfile", *pidfile) | ||
job.Setenv("Root", *flRoot) | ||
job.SetenvBool("AutoRestart", *flAutoRestart) | ||
job.SetenvList("Dns", flDns.GetAll()) | ||
job.SetenvList("DnsSearch", flDnsSearch.GetAll()) | ||
job.SetenvBool("EnableIptables", *flEnableIptables) | ||
job.SetenvBool("EnableIpForward", *flEnableIpForward) | ||
job.Setenv("BridgeIface", *bridgeName) | ||
job.Setenv("BridgeIP", *bridgeIp) | ||
job.Setenv("DefaultIp", *flDefaultIp) | ||
job.SetenvBool("InterContainerCommunication", *flInterContainerComm) | ||
job.Setenv("GraphDriver", *flGraphDriver) | ||
job.SetenvList("GraphOptions", flGraphOpts.GetAll()) | ||
job.Setenv("ExecDriver", *flExecDriver) | ||
job.SetenvInt("Mtu", *flMtu) | ||
job.SetenvBool("EnableSelinuxSupport", *flSelinuxEnabled) | ||
job.SetenvList("Sockets", flHosts.GetAll()) | ||
if err := job.Run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
// after the daemon is done setting up we can tell the api to start | ||
// accepting connections | ||
if err := eng.Job("acceptconnections").Run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
}() | ||
|
||
// TODO actually have a resolved graphdriver to show? | ||
log.Printf("docker daemon: %s %s; execdriver: %s; graphdriver: %s", | ||
dockerversion.VERSION, | ||
dockerversion.GITCOMMIT, | ||
*flExecDriver, | ||
*flGraphDriver) | ||
|
||
// Serve api | ||
job := eng.Job("serveapi", flHosts.GetAll()...) | ||
job.SetenvBool("Logging", true) | ||
job.SetenvBool("EnableCors", *flEnableCors) | ||
job.Setenv("Version", dockerversion.VERSION) | ||
job.Setenv("SocketGroup", *flSocketGroup) | ||
|
||
job.SetenvBool("Tls", *flTls) | ||
job.SetenvBool("TlsVerify", *flTlsVerify) | ||
job.Setenv("TlsCa", *flCa) | ||
job.Setenv("TlsCert", *flCert) | ||
job.Setenv("TlsKey", *flKey) | ||
job.SetenvBool("BufferRequests", true) | ||
if err := job.Run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Oops, something went wrong.