Skip to content

Commit e8d050c

Browse files
committed
feat: allow multiple -notify-sighup / -notify-container
1 parent ec10ca2 commit e8d050c

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ Options:
9999
run command after template is regenerated (e.g restart xyz)
100100
-notify-output
101101
log the output(stdout/stderr) of notify command
102+
-notify-sighup container-ID
103+
send HUP signal to container.
104+
Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`.
105+
You can pass this option multiple times to send HUP to multiple containers.
102106
-notify-container container-ID
103-
container to send a signal to
107+
send -notify-signal signal (defaults to 1 / HUP) to container.
108+
You can pass this option multiple times to notify multiple containers.
104109
-notify-filter key=value
105110
container filter for notification (e.g -notify-filter name=foo).
106111
You can have multiple of these.
@@ -109,8 +114,6 @@ Options:
109114
signal to send to the -notify-container and -notify-filter. -1 to call docker restart. Defaults to 1 aka. HUP.
110115
All available signals available on the dockerclient
111116
https://github.com/fsouza/go-dockerclient/blob/01804dec8a84d0a77e63611f2b62d33e9bb2b64a/signal.go
112-
-notify-sighup container-ID
113-
send HUP signal to container. Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`
114117
-only-exposed
115118
only include containers with exposed ports
116119
-only-published

cmd/docker-gen/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ var (
2626
wait string
2727
notifyCmd string
2828
notifyOutput bool
29-
sighupContainerID string
30-
notifyContainerID string
29+
sighupContainerID stringslice
30+
notifyContainerID stringslice
3131
notifyContainerSignal int
3232
notifyContainerFilter mapstringslice = make(mapstringslice)
3333
onlyExposed bool
@@ -112,10 +112,10 @@ func initFlags() {
112112
flag.BoolVar(&includeStopped, "include-stopped", false, "include stopped containers")
113113
flag.BoolVar(&notifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command")
114114
flag.StringVar(&notifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)")
115-
flag.StringVar(&sighupContainerID, "notify-sighup", "",
116-
"send HUP signal to container. Equivalent to docker kill -s HUP `container-ID`")
117-
flag.StringVar(&notifyContainerID, "notify-container", "",
118-
"container to send a signal to")
115+
flag.Var(&sighupContainerID, "notify-sighup",
116+
"send HUP signal to container. Equivalent to docker kill -s HUP `container-ID`. You can pass this option multiple times to send HUP to multiple containers.")
117+
flag.Var(&notifyContainerID, "notify-container",
118+
"send -notify-signal signal (defaults to 1 / HUP) to container. You can pass this option multiple times to notify multiple containers.")
119119
flag.Var(&notifyContainerFilter, "notify-filter",
120120
"container filter for notification (e.g -notify-filter name=foo). You can have multiple of these. https://docs.docker.com/engine/reference/commandline/ps/#filter")
121121
flag.IntVar(&notifyContainerSignal, "notify-signal", int(docker.SIGHUP),
@@ -176,11 +176,11 @@ func main() {
176176
Interval: interval,
177177
KeepBlankLines: keepBlankLines,
178178
}
179-
if sighupContainerID != "" {
180-
cfg.NotifyContainers[sighupContainerID] = int(syscall.SIGHUP)
179+
for _, id := range sighupContainerID {
180+
cfg.NotifyContainers[id] = int(syscall.SIGHUP)
181181
}
182-
if notifyContainerID != "" {
183-
cfg.NotifyContainers[notifyContainerID] = notifyContainerSignal
182+
for _, id := range notifyContainerID {
183+
cfg.NotifyContainers[id] = notifyContainerSignal
184184
}
185185
if len(notifyContainerFilter) > 0 {
186186
cfg.NotifyContainersFilter = notifyContainerFilter

0 commit comments

Comments
 (0)