|
23 | 23 | version bool |
24 | 24 | watch bool |
25 | 25 | notifyCmd string |
| 26 | + notifyOutput bool |
26 | 27 | notifySigHUPContainerID string |
27 | 28 | onlyExposed bool |
28 | 29 | onlyPublished bool |
@@ -128,6 +129,7 @@ type Config struct { |
128 | 129 | Dest string |
129 | 130 | Watch bool |
130 | 131 | NotifyCmd string |
| 132 | + NotifyOutput bool |
131 | 133 | NotifyContainers map[string]docker.Signal |
132 | 134 | OnlyExposed bool |
133 | 135 | OnlyPublished bool |
@@ -245,7 +247,13 @@ func runNotifyCmd(config Config) { |
245 | 247 | out, err := cmd.CombinedOutput() |
246 | 248 | if err != nil { |
247 | 249 | log.Printf("Error running notify command: %s, %s\n", config.NotifyCmd, err) |
248 | | - log.Print(string(out)) |
| 250 | + } |
| 251 | + if config.NotifyOutput { |
| 252 | + for _, line := range strings.Split(string(out), "\n") { |
| 253 | + if line != "" { |
| 254 | + log.Printf("[%s]: %s", config.NotifyCmd, line) |
| 255 | + } |
| 256 | + } |
249 | 257 | } |
250 | 258 | } |
251 | 259 |
|
@@ -406,6 +414,7 @@ func initFlags() { |
406 | 414 |
|
407 | 415 | flag.BoolVar(&onlyPublished, "only-published", false, |
408 | 416 | "only include containers with published ports (implies -only-exposed)") |
| 417 | + flag.BoolVar(¬ifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command") |
409 | 418 | flag.StringVar(¬ifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)") |
410 | 419 | flag.StringVar(¬ifySigHUPContainerID, "notify-sighup", "", |
411 | 420 | "send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`") |
@@ -448,6 +457,7 @@ func main() { |
448 | 457 | Dest: flag.Arg(1), |
449 | 458 | Watch: watch, |
450 | 459 | NotifyCmd: notifyCmd, |
| 460 | + NotifyOutput: notifyOutput, |
451 | 461 | NotifyContainers: make(map[string]docker.Signal), |
452 | 462 | OnlyExposed: onlyExposed, |
453 | 463 | OnlyPublished: onlyPublished, |
|
0 commit comments