Skip to content

Commit

Permalink
fix(enter): stop pebble if default services cannot start
Browse files Browse the repository at this point in the history
Exit with non-zero error code if waiting for the "change" (of default
services start) to be ready returns any errors.
  • Loading branch information
rebornplusplus committed Jul 11, 2023
1 parent 67b6eab commit 4098a71
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internals/cli/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func runDaemon(rcmd *cmdRun, ch chan os.Signal, ready chan<- func()) error {

logger.Debugf("activation done in %v", time.Now().Truncate(time.Millisecond).Sub(t0))

var autoStartReady chan struct{}
var autoStartReady chan error
var stop chan struct{}

notifyReady := func() {
Expand All @@ -214,17 +214,14 @@ func runDaemon(rcmd *cmdRun, ch chan os.Signal, ready chan<- func()) error {

if ready != nil {
// wait for the default services to start
autoStartReady = make(chan struct{}, 1)
autoStartReady = make(chan error, 1)
go func() {
waitCmd := waitMixin{
hideProgress: true,
}
waitCmd.setClient(rcmd.client)
_, err := waitCmd.wait(changeID)
if err != nil {
logger.Debugf("Error starting default services: %v", err)
}
autoStartReady <- struct{}{}
autoStartReady <- err
}()
}
} else if ready != nil {
Expand All @@ -246,7 +243,10 @@ out:
d.SetDegradedMode(nil)
tic.Stop()
}
case <-autoStartReady:
case chgErr := <-autoStartReady:
if chgErr != nil {
return fmt.Errorf("error starting default services: %w", chgErr)
}
notifyReady()
case <-stop:
break out
Expand Down

0 comments on commit 4098a71

Please sign in to comment.