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>
Engine.Shutdown only waits 5 seconds for active jobs to complete

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

This is part of the ongoing effort to remove the deprecated server/
package, and generally cleanup and simplify the codebase.

Signed-off-by: Solomon Hykes <solomon@docker.com>
Use only unavailable image when load from Tarball

Docker-DCO-1.1-Signed-off-by: Satoshi Amemiya <satoshi_amemiya@voyagegroup.com> (github: rail44)
fix parsing of hostnames when we actually want IP addresses.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
First stab at nat tests.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Update libcontainer to f2e78425c377acc7a67a35c3148

Signed-off-by: Michael Crosby <michael@docker.com>
Merge pull request #7475 from erikh/fix_hostname_parsing

fix parsing of hostnames when we actually want IP addresses.
Merge pull request #7492 from crosbymichael/update-libcontainer-aug3

Update libcontainer to f2e78425c377acc7a67a35c3148
Merge pull request #7449 from shykes/cleanup-shutdown

Cleanup: refactor shutdown and signal handling facility
Docs: Fix builds.md line-length + minor typo issues

This PR proposes to fix some already existing (i.e., older)
line-length & line-alignment issues and the ones recently
included/merged with the PR #7406
(https://github.com/docker/docker/pull/7406).

It also proposes to fix a couple minor typography mistakes
(i.e., spelling of GitHub and Service Hooks (headers))

This PR does *not* propose any content changes.

Docker-DCO-1.1-Signed-off-by: O.S. Tezer <ostezer@gmail.com> (github: ostezer)
fix for issue 7281
add missing comma per O.S. Tezer's commment

Signed-off-by: Doug Davis <dug@us.ibm.com>
Fix error message on logging events

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>