Commit fccd58a1 authored by Kamil Trzciński's avatar Kamil Trzciński 🔴

Don't send build trace if didn't change (will sent it anyway in 5 minutes)

parent dd5995b1
package common
import "time"
const DefaultTimeout = 7200
const CheckInterval = 3
const NotHealthyCheckInterval = 300
......@@ -11,3 +13,4 @@ const HealthCheckInterval = 3600
const DefaultWaitForServicesTimeout = 30
const ShutdownTimeout = 30
const MaxTraceOutputSize = 1024 * 1024 // 1MB
const ForceTraceSentInterval time.Duration = 300
......@@ -58,12 +58,25 @@ func (e *AbstractExecutor) PushTrace(config common.RunnerConfig, canceled chan b
return
}
lastSentTrace := -1
lastSentTime := time.Now()
for {
select {
case <-time.After(common.UpdateInterval * time.Second):
// check if build log changed
buildTraceLen := e.Build.BuildLogLen()
if buildTraceLen == lastSentTrace && time.Since(lastSentTime) > common.ForceTraceSentInterval {
e.Debugln("updateBuildLog", "Nothing to send.")
continue
}
buildTrace := e.Build.BuildLog()
switch common.UpdateBuild(config, e.Build.ID, common.Running, buildTrace) {
case common.UpdateSucceeded:
lastSentTrace = buildTraceLen
lastSentTime = time.Now()
case common.UpdateAbort:
e.Debugln("updateBuildLog", "Sending abort request...")
canceled <- true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment