Add log entries for daemon startup/shutdown
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
20ea8942b8
commit
595987fd08
3 changed files with 13 additions and 6 deletions
|
@ -91,6 +91,8 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
logrus.Info("Starting up")
|
||||
|
||||
cli.configFile = &opts.configFile
|
||||
cli.flags = opts.flags
|
||||
|
||||
|
@ -266,6 +268,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
|
|||
return errors.Wrap(errAPI, "shutting down due to ServeAPI error")
|
||||
}
|
||||
|
||||
logrus.Info("Daemon shutdown complete")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/docker/docker/pkg/homedir"
|
||||
"github.com/docker/libnetwork/portallocator"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
@ -152,6 +153,7 @@ func (cli *DaemonCli) initContainerD(ctx context.Context) (func(time.Duration) e
|
|||
return nil, errors.Wrap(err, "could not determine whether the system containerd is running")
|
||||
}
|
||||
if !ok {
|
||||
logrus.Debug("Containerd not running, starting daemon managed containerd")
|
||||
opts, err := cli.getContainerdDaemonOpts()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to generate containerd options")
|
||||
|
@ -161,6 +163,7 @@ func (cli *DaemonCli) initContainerD(ctx context.Context) (func(time.Duration) e
|
|||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to start containerd")
|
||||
}
|
||||
logrus.Debug("Started daemon managed containerd")
|
||||
cli.Config.ContainerdAddr = r.Address()
|
||||
|
||||
// Try to wait for containerd to shutdown
|
||||
|
|
|
@ -309,9 +309,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
|||
return errors.Errorf("[%s] Daemon exited and never started", d.id)
|
||||
case <-tick:
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Second)
|
||||
req := req.WithContext(ctx)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
resp, err := client.Do(req.WithContext(ctx))
|
||||
cancel()
|
||||
if err != nil {
|
||||
d.log.Logf("[%s] error pinging daemon on start: %v", d.id, err)
|
||||
|
@ -413,12 +411,16 @@ func (d *Daemon) Stop(t testingT) {
|
|||
// If it timeouts, a SIGKILL is sent.
|
||||
// Stop will not delete the daemon directory. If a purged daemon is needed,
|
||||
// instantiate a new one with NewDaemon.
|
||||
func (d *Daemon) StopWithError() error {
|
||||
func (d *Daemon) StopWithError() (err error) {
|
||||
if d.cmd == nil || d.Wait == nil {
|
||||
return errDaemonNotStarted
|
||||
}
|
||||
defer func() {
|
||||
d.log.Logf("[%s] Daemon stopped", d.id)
|
||||
if err == nil {
|
||||
d.log.Logf("[%s] Daemon stopped", d.id)
|
||||
} else {
|
||||
d.log.Logf("[%s] Error when stopping daemon: %v", d.id, err)
|
||||
}
|
||||
d.logFile.Close()
|
||||
d.cmd = nil
|
||||
}()
|
||||
|
@ -490,7 +492,6 @@ func (d *Daemon) Restart(t testingT, args ...string) {
|
|||
// RestartWithError will restart the daemon by first stopping it and then starting it.
|
||||
func (d *Daemon) RestartWithError(arg ...string) error {
|
||||
if err := d.StopWithError(); err != nil {
|
||||
d.log.Logf("[%s] Error when stopping daemon: %v", d.id, err)
|
||||
return err
|
||||
}
|
||||
return d.StartWithError(arg...)
|
||||
|
|
Loading…
Reference in a new issue