mirror of https://github.com/docker/compose.git
improve watch configuration logging
Add action associated to each managed path Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
d646d757a2
commit
e5cd265abb
|
@ -121,13 +121,14 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
|
||||||
dotGitIgnore,
|
dotGitIgnore,
|
||||||
)
|
)
|
||||||
|
|
||||||
var paths []string
|
var paths, pathLogs []string
|
||||||
for _, trigger := range config.Watch {
|
for _, trigger := range config.Watch {
|
||||||
if checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
|
if checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
|
||||||
logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path)
|
logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
paths = append(paths, trigger.Path)
|
paths = append(paths, trigger.Path)
|
||||||
|
pathLogs = append(pathLogs, fmt.Sprintf("Action %s for path %q", trigger.Action, trigger.Path))
|
||||||
}
|
}
|
||||||
|
|
||||||
watcher, err := watch.NewWatcher(paths, ignore)
|
watcher, err := watch.NewWatcher(paths, ignore)
|
||||||
|
@ -135,7 +136,12 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(s.stdinfo(), "watching %s\n", paths)
|
fmt.Fprintf(
|
||||||
|
s.stdinfo(),
|
||||||
|
"Watch configuration for service %q:%s\n",
|
||||||
|
service.Name,
|
||||||
|
strings.Join(append([]string{""}, pathLogs...), "\n - "),
|
||||||
|
)
|
||||||
err = watcher.Start()
|
err = watcher.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -420,7 +426,7 @@ func (s *composeService) handleWatchBatch(ctx context.Context, project *types.Pr
|
||||||
if batch[i].Action == types.WatchActionRebuild {
|
if batch[i].Action == types.WatchActionRebuild {
|
||||||
fmt.Fprintf(
|
fmt.Fprintf(
|
||||||
s.stdinfo(),
|
s.stdinfo(),
|
||||||
"Rebuilding %s after changes were detected:%s\n",
|
"Rebuilding service %q after changes were detected:%s\n",
|
||||||
serviceName,
|
serviceName,
|
||||||
strings.Join(append([]string{""}, batch[i].HostPath), "\n - "),
|
strings.Join(append([]string{""}, batch[i].HostPath), "\n - "),
|
||||||
)
|
)
|
||||||
|
@ -477,7 +483,7 @@ func writeWatchSyncMessage(w io.Writer, serviceName string, pathMappings []sync.
|
||||||
}
|
}
|
||||||
fmt.Fprintf(
|
fmt.Fprintf(
|
||||||
w,
|
w,
|
||||||
"Syncing %s after changes were detected:%s\n",
|
"Syncing %q after changes were detected:%s\n",
|
||||||
serviceName,
|
serviceName,
|
||||||
strings.Join(append([]string{""}, hostPathsToSync...), "\n - "),
|
strings.Join(append([]string{""}, hostPathsToSync...), "\n - "),
|
||||||
)
|
)
|
||||||
|
@ -488,7 +494,7 @@ func writeWatchSyncMessage(w io.Writer, serviceName string, pathMappings []sync.
|
||||||
}
|
}
|
||||||
fmt.Fprintf(
|
fmt.Fprintf(
|
||||||
w,
|
w,
|
||||||
"Syncing %s after %d changes were detected\n",
|
"Syncing service %q after %d changes were detected\n",
|
||||||
serviceName,
|
serviceName,
|
||||||
len(pathMappings),
|
len(pathMappings),
|
||||||
)
|
)
|
||||||
|
|
|
@ -106,7 +106,7 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
|
||||||
out := r.String()
|
out := r.String()
|
||||||
errors := r.String()
|
errors := r.String()
|
||||||
return strings.Contains(out,
|
return strings.Contains(out,
|
||||||
"watching"), fmt.Sprintf("'watching' not found in : \n%s\nStderr: \n%s\n", out,
|
"Watch configuration"), fmt.Sprintf("'Watch configuration' not found in : \n%s\nStderr: \n%s\n", out,
|
||||||
errors)
|
errors)
|
||||||
}, 30*time.Second, 1*time.Second)
|
}, 30*time.Second, 1*time.Second)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue