diff --git a/server/logging/log.go b/server/logging/log.go index 17758a797e..1fc956ab9d 100644 --- a/server/logging/log.go +++ b/server/logging/log.go @@ -79,9 +79,15 @@ func (l *log) Write(ctx context.Context, stepID int64, logEntry *model.LogEntry) l.Lock() s, ok := l.streams[stepID] l.Unlock() + + // auto open the stream if it does not exist if !ok { - return l.Open(ctx, stepID) + err := l.Open(ctx, stepID) + if err != nil { + return err + } } + s.Lock() s.list = append(s.list, logEntry) for sub := range s.subs { diff --git a/server/pipeline/create.go b/server/pipeline/create.go index e647a2cb04..ceb7efc09c 100644 --- a/server/pipeline/create.go +++ b/server/pipeline/create.go @@ -82,7 +82,7 @@ func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline err = _store.CreatePipeline(pipeline) if err != nil { msg := fmt.Errorf("failed to save pipeline for %s", repo.FullName) - log.Error().Err(err).Msg(msg.Error()) + log.Error().Str("repo", repo.FullName).Err(err).Msg(msg.Error()) return nil, msg } diff --git a/server/pipeline/decline.go b/server/pipeline/decline.go index 79838b46c7..21c3f1b1e8 100644 --- a/server/pipeline/decline.go +++ b/server/pipeline/decline.go @@ -30,7 +30,7 @@ func Decline(ctx context.Context, store store.Store, pipeline *model.Pipeline, u return nil, fmt.Errorf("cannot decline a pipeline with status %s", pipeline.Status) } - _, err := UpdateToStatusDeclined(store, *pipeline, user.Login) + pipeline, err := UpdateToStatusDeclined(store, *pipeline, user.Login) if err != nil { return nil, fmt.Errorf("error updating pipeline. %w", err) } diff --git a/server/pipeline/start.go b/server/pipeline/start.go index c6601e28fb..5ba505c572 100644 --- a/server/pipeline/start.go +++ b/server/pipeline/start.go @@ -20,7 +20,6 @@ import ( "github.com/rs/zerolog/log" "github.com/woodpecker-ci/woodpecker/pipeline" - "github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/store" ) @@ -45,18 +44,6 @@ func start(ctx context.Context, store store.Store, activePipeline *model.Pipelin return nil, err } - // open logs streamer for each step - for _, wf := range activePipeline.Workflows { - for _, step := range wf.Children { - stepID := step.ID - go func() { - if err := server.Config.Services.Logs.Open(context.Background(), stepID); err != nil { - log.Error().Err(err).Msgf("could not open log stream for step %d", stepID) - } - }() - } - } - return activePipeline, nil } diff --git a/web/src/views/repo/pipeline/PipelineWrapper.vue b/web/src/views/repo/pipeline/PipelineWrapper.vue index 0279617aea..e34bfcee02 100644 --- a/web/src/views/repo/pipeline/PipelineWrapper.vue +++ b/web/src/views/repo/pipeline/PipelineWrapper.vue @@ -8,7 +8,17 @@ :fluid-content="activeTab === 'tasks'" full-width-header > - +