mirror of https://github.com/docker/compose.git
Merge pull request #1200 from docker/fix_start_display
Fix compose start display
This commit is contained in:
commit
0c0c0bea6a
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/compose-cli/api/client"
|
||||
"github.com/docker/compose-cli/api/compose"
|
||||
"github.com/docker/compose-cli/api/progress"
|
||||
"github.com/docker/compose-cli/cli/formatter"
|
||||
)
|
||||
|
@ -55,21 +54,22 @@ func runStart(ctx context.Context, opts startOptions, services []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
var consumer compose.LogConsumer
|
||||
if !opts.Detach {
|
||||
consumer = formatter.NewLogConsumer(ctx, os.Stdout)
|
||||
}
|
||||
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
project, err := opts.toProject()
|
||||
if err != nil {
|
||||
return "", err
|
||||
return err
|
||||
}
|
||||
|
||||
err = filter(project, services)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return err
|
||||
}
|
||||
return "", c.ComposeService().Start(ctx, project, consumer)
|
||||
|
||||
if opts.Detach {
|
||||
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
return "", c.ComposeService().Start(ctx, project, nil)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
return c.ComposeService().Start(ctx, project, formatter.NewLogConsumer(ctx, os.Stdout))
|
||||
}
|
||||
|
|
|
@ -119,21 +119,27 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
|
|||
}
|
||||
|
||||
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
return "", c.ComposeService().Create(ctx, project, compose.CreateOptions{
|
||||
err := c.ComposeService().Create(ctx, project, compose.CreateOptions{
|
||||
RemoveOrphans: opts.removeOrphans,
|
||||
Recreate: opts.recreateStrategy(),
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if opts.Detach {
|
||||
err = c.ComposeService().Start(ctx, project, nil)
|
||||
}
|
||||
return "", err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var consumer compose.LogConsumer
|
||||
if !opts.Detach {
|
||||
consumer = formatter.NewLogConsumer(ctx, os.Stdout)
|
||||
if opts.Detach {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = c.ComposeService().Start(ctx, project, consumer)
|
||||
err = c.ComposeService().Start(ctx, project, formatter.NewLogConsumer(ctx, os.Stdout))
|
||||
if errors.Is(ctx.Err(), context.Canceled) {
|
||||
fmt.Println("Gracefully stopping...")
|
||||
ctx = context.Background()
|
||||
|
|
Loading…
Reference in New Issue