Skip to content

Commit

Permalink
tail: fix event loop (#238)
Browse files Browse the repository at this point in the history
Signed-off-by: Nandor Kracser <[email protected]>
  • Loading branch information
bonifaido authored Apr 29, 2020
1 parent fe534d2 commit e3175a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TailProcess(banzaiCli cli.Cli, processId string) error {
statuses := map[string]*spinner.Status{}

processVisibleChecks := 0
processedEvents := 0

for {
process, resp, err := client.ProcessesApi.GetProcess(context.Background(), orgID, processId)
Expand All @@ -53,7 +54,9 @@ func TailProcess(banzaiCli cli.Cli, processId string) error {
return errors.NewWithDetails("node pool update process list failed with http status code", "status_code", resp.StatusCode)
}

for i, event := range process.Events {
for i := processedEvents; i < len(process.Events); i++ {
event := process.Events[i]
processedEvents++
if s, ok := statuses[event.Type]; !ok {
status := spinner.NewStatus()
status.Start(fmt.Sprintf("[%s] executing %s activity %s", event.Timestamp.Local().Format(time.RFC3339), event.Type, event.Log))
Expand All @@ -64,6 +67,7 @@ func TailProcess(banzaiCli cli.Cli, processId string) error {
}
} else if event.Status != pipeline.RUNNING {
s.End(event.Status == pipeline.FINISHED)
delete(statuses, event.Type)
} else {
if i == len(process.Events)-1 {
time.Sleep(2 * time.Second)
Expand Down

0 comments on commit e3175a7

Please sign in to comment.