Skip to content

Commit 4dd369b

Browse files
ndeloofglours
authored andcommitted
fix sigint/sigterm support in logs --follow
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent ad73766 commit 4dd369b

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/compose/logs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func (s *composeService) Logs(
104104
}
105105
})
106106
eg.Go(func() error {
107+
// pass ctx so monitor will immediately stop on SIGINT
107108
return monitor.Start(ctx)
108109
})
109110
}

pkg/compose/monitor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (c *monitor) Start(ctx context.Context) error {
7979
}
8080
restarting := utils.Set[string]{}
8181

82-
evtCh, errCh := c.api.Events(context.Background(), events.ListOptions{
82+
evtCh, errCh := c.api.Events(ctx, events.ListOptions{
8383
Filters: filters.NewArgs(
8484
filters.Arg("type", "container"),
8585
projectFilter(c.project)),
@@ -89,6 +89,8 @@ func (c *monitor) Start(ctx context.Context) error {
8989
return nil
9090
}
9191
select {
92+
case <-ctx.Done():
93+
return nil
9294
case err := <-errCh:
9395
return err
9496
case event := <-evtCh:

0 commit comments

Comments
 (0)