mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
8d056423f8
* Events subsystem merged from `server/events.go` and `utils/jsonmessagepublisher.go` and moved to `events/events.go` * Only public interface for this subsystem is engine jobs * There is two new engine jobs - `log_event` and `subscribers_count` * There is auxiliary function `container.LogEvent` for logging events for containers Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4) [solomon@docker.com: resolve merge conflicts] Signed-off-by: Solomon Hykes <solomon@docker.com>
82 lines
2.3 KiB
Go
82 lines
2.3 KiB
Go
package builtins
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"github.com/docker/docker/api"
|
|
apiserver "github.com/docker/docker/api/server"
|
|
"github.com/docker/docker/daemon/networkdriver/bridge"
|
|
"github.com/docker/docker/dockerversion"
|
|
"github.com/docker/docker/engine"
|
|
"github.com/docker/docker/events"
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
|
"github.com/docker/docker/registry"
|
|
"github.com/docker/docker/server"
|
|
)
|
|
|
|
func Register(eng *engine.Engine) error {
|
|
if err := daemon(eng); err != nil {
|
|
return err
|
|
}
|
|
if err := remote(eng); err != nil {
|
|
return err
|
|
}
|
|
if err := events.New().Install(eng); err != nil {
|
|
return err
|
|
}
|
|
if err := eng.Register("version", dockerVersion); err != nil {
|
|
return err
|
|
}
|
|
return registry.NewService().Install(eng)
|
|
}
|
|
|
|
// remote: a RESTful api for cross-docker communication
|
|
func remote(eng *engine.Engine) error {
|
|
if err := eng.Register("serveapi", apiserver.ServeApi); err != nil {
|
|
return err
|
|
}
|
|
return eng.Register("acceptconnections", apiserver.AcceptConnections)
|
|
}
|
|
|
|
// daemon: a default execution and storage backend for Docker on Linux,
|
|
// with the following underlying components:
|
|
//
|
|
// * Pluggable storage drivers including aufs, vfs, lvm and btrfs.
|
|
// * Pluggable execution drivers including lxc and chroot.
|
|
//
|
|
// In practice `daemon` still includes most core Docker components, including:
|
|
//
|
|
// * The reference registry client implementation
|
|
// * Image management
|
|
// * The build facility
|
|
// * Logging
|
|
//
|
|
// These components should be broken off into plugins of their own.
|
|
//
|
|
func daemon(eng *engine.Engine) error {
|
|
if err := eng.Register("initserverpidfile", server.InitPidfile); err != nil {
|
|
return err
|
|
}
|
|
if err := eng.Register("initserver", server.InitServer); err != nil {
|
|
return err
|
|
}
|
|
return eng.Register("init_networkdriver", bridge.InitDriver)
|
|
}
|
|
|
|
// builtins jobs independent of any subsystem
|
|
func dockerVersion(job *engine.Job) engine.Status {
|
|
v := &engine.Env{}
|
|
v.SetJson("Version", dockerversion.VERSION)
|
|
v.SetJson("ApiVersion", api.APIVERSION)
|
|
v.Set("GitCommit", dockerversion.GITCOMMIT)
|
|
v.Set("GoVersion", runtime.Version())
|
|
v.Set("Os", runtime.GOOS)
|
|
v.Set("Arch", runtime.GOARCH)
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
|
v.Set("KernelVersion", kernelVersion.String())
|
|
}
|
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
|
return job.Error(err)
|
|
}
|
|
return engine.StatusOK
|
|
}
|