Skip to content

Commit

Permalink
Merge pull request #21 from scraperwiki/exit-improvements
Browse files Browse the repository at this point in the history
Improvements to container exit reliability
  • Loading branch information
frabcus committed Dec 9, 2014
2 parents dff1c9c + cf08384 commit 514e106
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,14 @@ func (c *Container) Start() error {
err := c.client.KillContainer(docker.KillContainerOptions{
ID: c.container.ID,
})
if err != nil {
if err == nil {
return
}
switch err := err.(type) {
case *docker.NoSuchContainer:
// The container already went away, who cares.
return
default:
log.Println("Killing container failed:", c.container.ID, err)
}
}()
Expand All @@ -203,6 +210,7 @@ func (c *Container) err(err error) {
// start it.
func (c *Container) Run(event UpdateEvent) (int, error) {

defer c.Closing.Fall()
defer close(c.errorsW)

err := c.Build(event)
Expand Down Expand Up @@ -240,9 +248,12 @@ func (c *Container) Run(event UpdateEvent) (int, error) {
}

func (c *Container) Delete() {
c.client.RemoveContainer(docker.RemoveContainerOptions{
err := c.client.RemoveContainer(docker.RemoveContainerOptions{
ID: c.container.ID,
RemoveVolumes: true,
Force: true,
})
if err != nil {
log.Println("Warn: failed to delete container:", err)
}
}

0 comments on commit 514e106

Please sign in to comment.