Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AI_AGENT_DISCLOSURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This contribution was prepared by an AI agent acting on a human's behalf.
The human submitter may not have independently reviewed or tested the change.
2026-08-23
2 changes: 1 addition & 1 deletion pkg/compose/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type progressFunc func(context.Context) error
func Run(ctx context.Context, pf progressFunc, operation string, bus api.EventProcessor) error {
bus.Start(ctx, operation)
err := pf(ctx)
bus.Done(operation, err != nil)
bus.Done(operation, err == nil)
return err
}

Expand Down
18 changes: 7 additions & 11 deletions pkg/compose/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
type WatchFunc func(ctx context.Context, project *types.Project, options api.WatchOptions) (func() error, error)

type Watcher struct {
mx gsync.Mutex
project *types.Project
options api.WatchOptions
watchFn WatchFunc
Expand Down Expand Up @@ -78,30 +79,25 @@ func NewWatcher(project *types.Project, options api.UpOptions, w WatchFunc, cons
return nil, fmt.Errorf("none of the selected services is configured for watch, see https://docs.docker.com/compose/how-tos/file-watch/")
}

// ensure state changes are atomic
var mx gsync.Mutex

func (w *Watcher) Start(ctx context.Context) error {
mx.Lock()
defer mx.Unlock()
w.mx.Lock()
defer w.mx.Unlock()
ctx, cancelFunc := context.WithCancel(ctx)
w.stopFn = cancelFunc
wait, err := w.watchFn(ctx, w.project, w.options)
if err != nil {
go func() {
w.errCh <- err
}()
cancelFunc()
return err
}
w.stopFn = cancelFunc
go func() {
w.errCh <- wait()
}()
return nil
}

func (w *Watcher) Stop() error {
mx.Lock()
defer mx.Unlock()
w.mx.Lock()
defer w.mx.Unlock()
if w.stopFn == nil {
return nil
}
Expand Down