func NewClientLogger(client client.Client, id int64, rc io.ReadCloser, wc io.WriteCloser, limit int64) LoggerFunc { var once sync.Once var size int64 return func(line *build.Line) { // annoying hack to only start streaming once the first line is written once.Do(func() { go func() { err := client.Stream(id, rc) if err != nil && err != io.ErrClosedPipe { logrus.Errorf("Error streaming build logs. %s", err) } }() }) if size > limit { return } linejson, _ := json.Marshal(line) wc.Write(linejson) wc.Write([]byte{'\n'}) size += int64(len(line.Out)) } }
func pushRetry(client client.Client, w *queue.Work) { for { err := client.Push(w) if err == nil { return } logrus.Errorf("Error updating %s/%s#%d.%d. Retry in 30s. %s", w.Repo.Owner, w.Repo.Name, w.Build.Number, w.Job.Number, err) logrus.Infof("Retry update in 30s") time.Sleep(time.Second * 30) } }