|
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
|
@@ -115,6 +116,7 @@ type Config struct {
|
115 | 116 | Dest string
|
116 | 117 | Watch bool
|
117 | 118 | NotifyCmd string
|
| 119 | + NotifyOutput bool |
118 | 120 | NotifyContainers map[string]docker.Signal
|
119 | 121 | OnlyExposed bool
|
120 | 122 | OnlyPublished bool
|
@@ -232,7 +234,13 @@ func runNotifyCmd(config Config) {
|
232 | 234 | out, err := cmd.CombinedOutput()
|
233 | 235 | if err != nil {
|
234 | 236 | log.Printf("Error running notify command: %s, %s\n", config.NotifyCmd, err)
|
235 |
| - log.Print(string(out)) |
| 237 | + } |
| 238 | + if config.NotifyOutput { |
| 239 | + for _, line := range strings.Split(string(out), "\n") { |
| 240 | + if line != "" { |
| 241 | + log.Printf("[%s]: %s", config.NotifyCmd, line) |
| 242 | + } |
| 243 | + } |
236 | 244 | }
|
237 | 245 | }
|
238 | 246 |
|
@@ -393,6 +401,7 @@ func initFlags() {
|
393 | 401 |
|
394 | 402 | flag.BoolVar(&onlyPublished, "only-published", false,
|
395 | 403 | "only include containers with published ports (implies -only-exposed)")
|
| 404 | + flag.BoolVar(¬ifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command") |
396 | 405 | flag.StringVar(¬ifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)")
|
397 | 406 | flag.StringVar(¬ifySigHUPContainerID, "notify-sighup", "",
|
398 | 407 | "send HUP signal to container. Equivalent to `docker kill -s HUP container-ID`")
|
@@ -435,6 +444,7 @@ func main() {
|
435 | 444 | Dest: flag.Arg(1),
|
436 | 445 | Watch: watch,
|
437 | 446 | NotifyCmd: notifyCmd,
|
| 447 | + NotifyOutput: notifyOutput, |
438 | 448 | NotifyContainers: make(map[string]docker.Signal),
|
439 | 449 | OnlyExposed: onlyExposed,
|
440 | 450 | OnlyPublished: onlyPublished,
|
|
0 commit comments