Skip to content

Commit

Permalink
Wait for service monitor to finish even if log tail fails
Browse files Browse the repository at this point in the history
  • Loading branch information
edw-defang committed Jul 2, 2024
1 parent 6b840c7 commit 686c82d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cmd/cli/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"regexp"
"slices"
"strings"
"sync"
"time"

"github.com/AlecAivazis/survey/v2"
Expand Down Expand Up @@ -826,6 +827,8 @@ var composeUpCmd = &cobra.Command{

tailCtx, cancelTail := context.WithCancel(ctx)

var wg sync.WaitGroup
wg.Add(1)
go func() { // Cancel the tailing if the service is ready
if err := waitServiceStatus(ctx, cli.ServiceStarted, serviceInfos); err != nil {
if !errors.Is(err, context.Canceled) &&
Expand All @@ -845,10 +848,13 @@ var composeUpCmd = &cobra.Command{
if err := startTailing(tailCtx, deploy.Etag, since); err != nil {
var cerr *cli.CancelError
if !errors.As(err, &cerr) {
term.Debugf("failed to start tailing: %v", err)
term.Warnf("failed to start tailing, you will not be able to see logs: %v", err)
} else {
term.Debugf("tailing cancelled: %v", err)
}
}

wg.Wait() // Wait for the service status monitoring to finish
printEndpoints(serviceInfos)
term.Info("Done.")
return nil
Expand Down

0 comments on commit 686c82d

Please sign in to comment.