Move "image_export" to graph/export.go

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "image_history" to graph/history.go

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "images" to graph/list.go

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "viz" to graph/viz.go

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "load" to graph/load.go

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "import" to graph/import.go

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "image_delete" to daemon/image_delete.go

Note: this cannot yet be moved to graph/ because of a lingering
dependency on daemon. This has been noted in a FIXME.

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move "image_tag" and "tag" to graph/tag.go

Note: these 2 jobs should be merged into one. This was noted in a FIXME.

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move some integration tests to integration-cli

Signed-off-by: Tibor Vass <teabee89@gmail.com>
Check error returned by eng.Register() in TagStore.Install()

Signed-off-by: Tibor Vass <teabee89@gmail.com>
Separate events subsystem

* 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>
Rename "log_event" to "log"

Signed-off-by: Solomon Hykes <solomon@docker.com>
Subsystems can register cleanup handlers with Engine.OnShutdown

Signed-off-by: Solomon Hykes <solomon@docker.com>
Move signal handling code to pkg/signal.Trap

Signed-off-by: Solomon Hykes <solomon@docker.com>
Cleanup: refactor shutdown and signal handling facility

This disentangles the following functions, which were previously all mixed together:

* 1) Waiting for jobs to terminate when shutting down
* 2) Handling signals in the Docker daemon
* 3) Per-subsystem cleanup handlers
* 4) pidfile management

Responsibilities are dispatched as follows:

* Signal traps are set in `main`, and trigger `engine.Shutdown`
* `engine.Shutdown` coordinates cleanup by waiting for jobs to complete, and calling shutdown handlers
* To perform cleanup at shutdown, each subsystem registers handlers with `engine.OnShutdown`
* `daemon` is one subsystem, so it registers cleanup via `engine.OnShutdown`.
* `daemon` owns the pidfile, which is used to lock access to `/var/lib/docker`. Part of its cleanup is to remove the pidfile.

Signed-off-by: Solomon Hykes <solomon@docker.com>
Remove unnecessary job "initserverpidfile"

That job was a hacky solution to a real race condition. This removes the
hack without re-introducing the race.

Signed-off-by: Solomon Hykes <solomon@docker.com>
Replace Server.IsRunning with Engine.IsShutdown

Signed-off-by: Solomon Hykes <solomon@docker.com>
Extra testing for engine.Shutdown

Signed-off-by: Solomon Hykes <solomon@docker.com>
Remove last trace of Daemon->Server dependency

This removes a shim `daemon.Server` interface which was used to start
separating Daemon from Server *gradually*, without getting cyclic
dependency errors.

Now that the last Daemon->Server dependency has been removed, we can
finally remove the shim. Yay!

Signed-off-by: Solomon Hykes <solomon@docker.com>
Remove unused field from engine.Job

Signed-off-by: Solomon Hykes <solomon@docker.com>