Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

FIX for application restart when srv not reachable #595

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions javascripts/dashing.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,21 @@ source = new EventSource('events')
source.addEventListener 'open', (e) ->
console.log("Connection opened", e)

errorTimerId = null

source.addEventListener 'error', (e)->
console.log("Connection error", e)
if (e.currentTarget.readyState == EventSource.CLOSED)
UNINITIALIZED = 0
if (e.currentTarget.readyState == UNINITIALIZED ||
e.currentTarget.readyState == EventSource.CLOSED)
console.log("Connection closed")
setTimeout (->
errorTimerId = setTimeout (->
window.location.reload()
), 5*60*1000

source.addEventListener 'message', (e) ->
clearTimeout(errorTimerId)
errorTimerId = null
data = JSON.parse(e.data)
if lastEvents[data.id]?.updatedAt != data.updatedAt
if Dashing.debugMode
Expand All @@ -123,3 +129,4 @@ source.addEventListener 'dashboards', (e) ->

$(document).ready ->
Dashing.run()