diff --git a/pkg/console/console.go b/pkg/console/console.go index fe2e90b0..2a4cb33e 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -16,11 +16,10 @@ package console import ( "fmt" - "os/exec" - "github.com/hashicorp/go-multierror" "github.com/mudler/yip/pkg/logger" "github.com/sirupsen/logrus" + "os/exec" ) type StandardConsole struct { @@ -54,6 +53,7 @@ func (s StandardConsole) Run(cmd string, opts ...func(cmd *exec.Cmd)) (string, e o(c) } out, err := c.CombinedOutput() + if err != nil { return string(out), fmt.Errorf("failed to run %s: %v", cmd, err) } diff --git a/pkg/executor/default.go b/pkg/executor/default.go index 47f453d9..d5151234 100644 --- a/pkg/executor/default.go +++ b/pkg/executor/default.go @@ -21,6 +21,7 @@ import ( "github.com/sanity-io/litter" "os" "path/filepath" + "time" "github.com/hashicorp/go-multierror" "github.com/mudler/yip/pkg/logger" @@ -94,14 +95,31 @@ func (e *DefaultExecutor) applyStage(config schema.YipConfig, stageName string, e.logger.Debugf("Stage: %s", litter.Sdump(stage)) for _, p := range e.plugins { + ctx, cancel := context.WithCancel(context.Background()) + go stillAlive(ctx, e.logger, 10*time.Second, fmt.Sprintf("Still running stage '%s'", stageName)) if err := p(e.logger, stage, fs, console); err != nil { e.logger.Errorf("Error on file %s on stage %s: %s", config.Source, stage.Name, err) errs = multierror.Append(errs, err) } + cancel() } return errs } +func stillAlive(ctx context.Context, log logger.Interface, tick time.Duration, message string) { + ticker := time.NewTicker(tick) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + log.Info(message) + } + } +} + func checkDuplicates(stages []schema.Stage) bool { stageNames := map[string]bool{} for _, st := range stages {