|
@@ -4,12 +4,10 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
- "github.com/dotcloud/docker/api"
|
|
|
|
"github.com/dotcloud/docker/archive"
|
|
"github.com/dotcloud/docker/archive"
|
|
"github.com/dotcloud/docker/auth"
|
|
"github.com/dotcloud/docker/auth"
|
|
"github.com/dotcloud/docker/engine"
|
|
"github.com/dotcloud/docker/engine"
|
|
"github.com/dotcloud/docker/pkg/graphdb"
|
|
"github.com/dotcloud/docker/pkg/graphdb"
|
|
- "github.com/dotcloud/docker/pkg/systemd"
|
|
|
|
"github.com/dotcloud/docker/registry"
|
|
"github.com/dotcloud/docker/registry"
|
|
"github.com/dotcloud/docker/utils"
|
|
"github.com/dotcloud/docker/utils"
|
|
"io"
|
|
"io"
|
|
@@ -35,13 +33,13 @@ func (srv *Server) Close() error {
|
|
}
|
|
}
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
- engine.Register("initapi", jobInitApi)
|
|
|
|
|
|
+ engine.Register("initserver", jobInitServer)
|
|
}
|
|
}
|
|
|
|
|
|
// jobInitApi runs the remote api server `srv` as a daemon,
|
|
// jobInitApi runs the remote api server `srv` as a daemon,
|
|
// Only one api server can run at the same time - this is enforced by a pidfile.
|
|
// Only one api server can run at the same time - this is enforced by a pidfile.
|
|
// The signals SIGINT, SIGQUIT and SIGTERM are intercepted for cleanup.
|
|
// The signals SIGINT, SIGQUIT and SIGTERM are intercepted for cleanup.
|
|
-func jobInitApi(job *engine.Job) engine.Status {
|
|
|
|
|
|
+func jobInitServer(job *engine.Job) engine.Status {
|
|
job.Logf("Creating server")
|
|
job.Logf("Creating server")
|
|
srv, err := NewServer(job.Eng, DaemonConfigFromJob(job))
|
|
srv, err := NewServer(job.Eng, DaemonConfigFromJob(job))
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -77,7 +75,6 @@ func jobInitApi(job *engine.Job) engine.Status {
|
|
"restart": srv.ContainerRestart,
|
|
"restart": srv.ContainerRestart,
|
|
"start": srv.ContainerStart,
|
|
"start": srv.ContainerStart,
|
|
"kill": srv.ContainerKill,
|
|
"kill": srv.ContainerKill,
|
|
- "serveapi": srv.ListenAndServe,
|
|
|
|
"wait": srv.ContainerWait,
|
|
"wait": srv.ContainerWait,
|
|
"tag": srv.ImageTag,
|
|
"tag": srv.ImageTag,
|
|
"resize": srv.ContainerResize,
|
|
"resize": srv.ContainerResize,
|
|
@@ -112,33 +109,6 @@ func jobInitApi(job *engine.Job) engine.Status {
|
|
return engine.StatusOK
|
|
return engine.StatusOK
|
|
}
|
|
}
|
|
|
|
|
|
-// ListenAndServe loops through all of the protocols sent in to docker and spawns
|
|
|
|
-// off a go routine to setup a serving http.Server for each.
|
|
|
|
-func (srv *Server) ListenAndServe(job *engine.Job) engine.Status {
|
|
|
|
- protoAddrs := job.Args
|
|
|
|
- chErrors := make(chan error, len(protoAddrs))
|
|
|
|
-
|
|
|
|
- for _, protoAddr := range protoAddrs {
|
|
|
|
- protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
|
|
|
- go func() {
|
|
|
|
- log.Printf("Listening for HTTP on %s (%s)\n", protoAddrParts[0], protoAddrParts[1])
|
|
|
|
- chErrors <- api.ListenAndServe(protoAddrParts[0], protoAddrParts[1], srv.Eng, job.GetenvBool("Logging"), job.GetenvBool("EnableCors"), VERSION)
|
|
|
|
- }()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for i := 0; i < len(protoAddrs); i += 1 {
|
|
|
|
- err := <-chErrors
|
|
|
|
- if err != nil {
|
|
|
|
- return job.Error(err)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Tell the init daemon we are accepting requests
|
|
|
|
- go systemd.SdNotify("READY=1")
|
|
|
|
-
|
|
|
|
- return engine.StatusOK
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// simpleVersionInfo is a simple implementation of
|
|
// simpleVersionInfo is a simple implementation of
|
|
// the interface VersionInfo, which is used
|
|
// the interface VersionInfo, which is used
|
|
// to provide version information for some product,
|
|
// to provide version information for some product,
|