fix sigint/sigterm support in logs --follow

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof
2025-09-01 15:35:45 +02:00
committed by Guillaume Lours
parent ad73766bf2
commit 4dd369bdcb
2 changed files with 4 additions and 1 deletions

View File

@@ -104,6 +104,7 @@ func (s *composeService) Logs(
}
})
eg.Go(func() error {
// pass ctx so monitor will immediately stop on SIGINT
return monitor.Start(ctx)
})
}

View File

@@ -79,7 +79,7 @@ func (c *monitor) Start(ctx context.Context) error {
}
restarting := utils.Set[string]{}
evtCh, errCh := c.api.Events(context.Background(), events.ListOptions{
evtCh, errCh := c.api.Events(ctx, events.ListOptions{
Filters: filters.NewArgs(
filters.Arg("type", "container"),
projectFilter(c.project)),
@@ -89,6 +89,8 @@ func (c *monitor) Start(ctx context.Context) error {
return nil
}
select {
case <-ctx.Done():
return nil
case err := <-errCh:
return err
case event := <-evtCh: