| 575 | } |
| 576 | |
| 577 | func (cli *daemonCLI) stop() { |
| 578 | // Signal that the API server should shut down as soon as possible. |
| 579 | // This construct is used rather than directly shutting down the HTTP |
| 580 | // server to avoid any issues if this method is called before the server |
| 581 | // has been instantiated in cli.start(). If this method is called first, |
| 582 | // the HTTP server will be shut down immediately upon instantiation. |
| 583 | cli.stopOnce.Do(func() { |
| 584 | close(cli.apiShutdown) |
| 585 | }) |
| 586 | } |
| 587 | |
| 588 | // shutdownDaemon just wraps daemon.Shutdown() to handle a timeout in case |
| 589 | // d.Shutdown() is waiting too long to kill container or worst it's |