mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Refactor container.Start()
This commit is contained in:
parent
664acd2971
commit
ed6ca109bf
1 changed files with 233 additions and 237 deletions
16
container.go
16
container.go
|
@ -563,11 +563,14 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
|
|||
})
|
||||
}
|
||||
|
||||
func (container *Container) Start(hostConfig *HostConfig) error {
|
||||
func (container *Container) Start(hostConfig *HostConfig) (err error) {
|
||||
container.State.Lock()
|
||||
defer container.State.Unlock()
|
||||
|
||||
startFct := func(hostConfig *HostConfig) error {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
container.cleanup()
|
||||
}
|
||||
}()
|
||||
|
||||
if hostConfig == nil { // in docker start of docker restart we want to reuse previous HostConfigFile
|
||||
hostConfig, _ = container.ReadHostConfig()
|
||||
|
@ -805,7 +808,6 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
|||
|
||||
container.cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||
|
||||
var err error
|
||||
if container.Config.Tty {
|
||||
err = container.startPty()
|
||||
} else {
|
||||
|
@ -826,12 +828,6 @@ func (container *Container) Start(hostConfig *HostConfig) error {
|
|||
go container.monitor(hostConfig)
|
||||
return nil
|
||||
}
|
||||
err := startFct(hostConfig)
|
||||
if err != nil {
|
||||
container.cleanup()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (container *Container) Run() error {
|
||||
hostConfig := &HostConfig{}
|
||||
|
|
Loading…
Add table
Reference in a new issue