Skip to content
This repository was archived by the owner on Feb 24, 2023. It is now read-only.

Commit 136a9ce

Browse files
Merge pull request #7 from apatil/master
Systemd-docker client detaches if -d option is given by user
2 parents faf1c44 + e21afab commit 136a9ce

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

main.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type Context struct {
4343
Pid int
4444
PidFile string
4545
Client *dockerClient.Client
46+
Detach bool
4647
}
4748

4849
func setupEnvironment(c *Context) {
@@ -82,6 +83,7 @@ func parseContext(args []string) (*Context, error) {
8283
flags.BoolVar(&c.Notify, []string{"n", "-notify"}, false, "setup systemd notify for container")
8384
flags.BoolVar(&c.Env, []string{"e", "-env"}, false, "inherit environment variable")
8485
flags.Var(&flCgroups, []string{"c", "-cgroups"}, "cgroups to take ownership of or 'all' for all cgroups available")
86+
flags.BoolVar(&c.Detach, []string{"d", "-detach"}, false, "detach from container")
8587

8688
err := flags.Parse(args)
8789
if err != nil {
@@ -550,16 +552,18 @@ func mainWithArgs(args []string) (*Context, error) {
550552
return c, err
551553
}
552554

553-
go pipeLogs(c)
555+
if !c.Detach {
556+
go pipeLogs(c)
554557

555-
err = keepAlive(c)
556-
if err != nil {
557-
return c, err
558-
}
558+
err = keepAlive(c)
559+
if err != nil {
560+
return c, err
561+
}
559562

560-
err = rmContainer(c)
561-
if err != nil {
562-
return c, err
563+
err = rmContainer(c)
564+
if err != nil {
565+
return c, err
566+
}
563567
}
564568

565569
return c, nil

0 commit comments

Comments
 (0)