mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
build: fix issues with leaving invoke containers running
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@ -52,10 +52,8 @@ func RunMonitor(ctx context.Context, containerConfig build.ContainerConfig, relo
|
||||
}
|
||||
|
||||
// Start container automatically
|
||||
go func() {
|
||||
fmt.Fprintf(stdout, "Launching interactive container. Press Ctrl-a-c to switch to monitor console\n")
|
||||
m.rollback(ctx, containerConfig)
|
||||
}()
|
||||
fmt.Fprintf(stdout, "Launching interactive container. Press Ctrl-a-c to switch to monitor console\n")
|
||||
m.rollback(ctx, containerConfig)
|
||||
|
||||
// Serve monitor commands
|
||||
monitorForwarder := newIOForwarder(monitorIn)
|
||||
@ -67,6 +65,10 @@ func RunMonitor(ctx context.Context, containerConfig build.ContainerConfig, relo
|
||||
go func() {
|
||||
defer close(doneCh)
|
||||
defer in.Close()
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
in.Close()
|
||||
}()
|
||||
t := term.NewTerminal(readWriter{in.stdin, in.stdout}, "(buildx) ")
|
||||
for {
|
||||
l, err := t.ReadLine()
|
||||
@ -105,8 +107,14 @@ func RunMonitor(ctx context.Context, containerConfig build.ContainerConfig, relo
|
||||
}()
|
||||
select {
|
||||
case <-doneCh:
|
||||
if m.curInvokeCancel != nil {
|
||||
m.curInvokeCancel()
|
||||
}
|
||||
return nil
|
||||
case err := <-errCh:
|
||||
if m.curInvokeCancel != nil {
|
||||
m.curInvokeCancel()
|
||||
}
|
||||
return err
|
||||
case <-monitorDisableCh:
|
||||
}
|
||||
|
Reference in New Issue
Block a user