diff options
author | bob <bcz@cs.brown.edu> | 2019-12-02 13:22:02 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-12-02 13:22:02 -0500 |
commit | 1ef06e189a352e5472ee267d44d4b3c96042f03c (patch) | |
tree | eefed629be388e83dc71a7b3c574326fc0343f06 /src/client/util/ClientDiagnostics.ts | |
parent | 1280c005829cf49fd106fd872afcf4ed6593a2f6 (diff) | |
parent | 0595f93dde717b7b6990e9a81c5b43a73a3808d5 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/util/ClientDiagnostics.ts')
-rw-r--r-- | src/client/util/ClientDiagnostics.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/client/util/ClientDiagnostics.ts b/src/client/util/ClientDiagnostics.ts new file mode 100644 index 000000000..0a213aa1c --- /dev/null +++ b/src/client/util/ClientDiagnostics.ts @@ -0,0 +1,34 @@ +export namespace ClientDiagnostics { + + export async function start() { + + let serverPolls = 0; + const serverHandle = setInterval(async () => { + if (++serverPolls === 20) { + alert("Your connection to the server has been terminated."); + clearInterval(serverHandle); + } + await fetch("/serverHeartbeat"); + serverPolls--; + }, 1000 * 15); + + let executed = false; + let solrHandle: NodeJS.Timeout | undefined; + const handler = async () => { + const response = await fetch("/solrHeartbeat"); + if (!(await response.json()).running) { + if (!executed) { + alert("Looks like SOLR is not running on your machine."); + executed = true; + solrHandle && clearInterval(solrHandle); + } + } + }; + await handler(); + if (!executed) { + solrHandle = setInterval(handler, 1000 * 15); + } + + } + +}
\ No newline at end of file |