Skip to content

Commit

Permalink
Can now give rm arg to run command
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Feb 9, 2016
1 parent 9b881b5 commit 18c0a87
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions configparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ func (f *ConfigParser) parseSettings(lines [][]byte) (projSettings *ProjectConfi

setting.Links = append(setting.Links, newLink)

case "rm":
setting.Remove = true
case "hook":
if len(args) > 0 {
curHooks := setting.Hooks
Expand Down
29 changes: 21 additions & 8 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ type Container struct {
ProjectNameSeparator string
// the number of this container, relates to scale
InstanceNumber int

// Rm command given, therefore dont run as daemon
Remove bool
}

// Builds an image for a container
Expand All @@ -154,13 +157,19 @@ func (set *Container) runInForeground(cmd []interface{}, wg *sync.WaitGroup) err

beforeStart := time.Now()

cmd = append([]interface{}{
"run",
"-a", "stdout",
"-a", "stderr",
"-a", "stdin",
"--sig-proxy=false",
}, cmd...)
initialArgs := []interface{}{
"run",
"-a", "stdout",
"-a", "stderr",
"-a", "stdin",
"--sig-proxy=false",
}

if set.Remove {
initialArgs = append(initialArgs, "--rm")
}

cmd = append(initialArgs, cmd...)
if ses, err = set.startLoggedCommand(cmd); err != nil {
return err
}
Expand Down Expand Up @@ -256,7 +265,11 @@ func (set *Container) Run(attach bool, dryRun bool, wg *sync.WaitGroup) error {
}

} else {
cmd = append([]interface{}{"run", "-d"}, cmd...)
daemonOrRmArg := "-d"
if set.Remove {
daemonOrRmArg = "--rm"
}
cmd = append([]interface{}{"run", daemonOrRmArg}, cmd...)
if err := set.launchDaemonCommand(cmd); err != nil {
return err
}
Expand Down

0 comments on commit 18c0a87

Please sign in to comment.