diff --git a/.gitignore b/.gitignore index 00cfda47..95b2417d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ release/ scripts/*.go docker/**/data TODO* +.idea diff --git a/handler/api/events/build.go b/handler/api/events/build.go index caa8abc5..4930abff 100644 --- a/handler/api/events/build.go +++ b/handler/api/events/build.go @@ -82,6 +82,7 @@ func HandleEvents( events, errc := events.Subscribe(ctx) logger.Debugln("events: stream opened") + timeoutChan := time.After(24 * time.Hour) L: for { select { @@ -91,7 +92,7 @@ func HandleEvents( case <-errc: logger.Debugln("events: stream error") break L - case <-time.After(time.Hour): + case <-timeoutChan: logger.Debugln("events: stream timeout") break L case <-time.After(pingInterval): diff --git a/handler/api/events/global.go b/handler/api/events/global.go index 6d13a7af..25651bcf 100644 --- a/handler/api/events/global.go +++ b/handler/api/events/global.go @@ -63,6 +63,7 @@ func HandleGlobal( events, errc := events.Subscribe(ctx) logger.Debugln("events: stream opened") + timeoutChan := time.After(24 * time.Hour) L: for { select { @@ -72,7 +73,7 @@ func HandleGlobal( case <-errc: logger.Debugln("events: stream error") break L - case <-time.After(time.Hour): + case <-timeoutChan: logger.Debugln("events: stream timeout") break L case <-time.After(pingInterval): diff --git a/handler/api/events/logs.go b/handler/api/events/logs.go index be86597f..8f5fdf67 100644 --- a/handler/api/events/logs.go +++ b/handler/api/events/logs.go @@ -102,6 +102,7 @@ func HandleLogStream( return } + timeoutChan := time.After(24 * time.Hour) L: for { select { @@ -109,7 +110,7 @@ func HandleLogStream( break L case <-errc: break L - case <-time.After(time.Hour): + case <-timeoutChan: break L case <-time.After(pingInterval): io.WriteString(w, ": ping\n\n")