changeset 1958:e0dd7fa987ea

stats: retry downed servers so their stats wake up when they do Ignore-this: dbb695fd829292af2450065603cd8d7e
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 06 Jun 2019 10:02:19 +0000
parents a745bee5c419
children 5633155c0300
files light9/web/index.html light9/web/stats-line.js light9/web/stats-process.js
diffstat 3 files changed, 29 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/index.html	Thu Jun 06 09:31:36 2019 +0000
+++ b/light9/web/index.html	Thu Jun 06 10:02:19 2019 +0000
@@ -8,10 +8,8 @@
     <link rel="import" href="/lib/polymer/polymer.html">
   </head>
   <body>
-      <script type="module"  src="stats-line.js"></script>
-      <script type="module"  src="stats-process.js"></script>
-
-
+    <script type="module" src="stats-line.js"></script>
+    <script type="module" src="stats-process.js"></script>
      
     <dom-module id="service-button-row">
       <template>
@@ -41,32 +39,27 @@
          :host > div:nth-child(3) { width: 5em; }
          :host > div:nth-child(4) { width: 3em; }
          :host > div:nth-child(5) { width: 50px; }
-         
         </style>
 
-
-          <div class="left"><a class="big" href="{{name}}/">{{name}}</a></div>
-          <div class="window"><button on-click="click">window</button></div>
-          <div><a href="{{name}}/stats/">stats</a></div>
-          <div id="stats"><stats-line name="{{name}}"></div>
-
-        
+        <div class="left"><a class="big" href="{{name}}/">{{name}}</a></div>
+        <div class="window"><button on-click="click">window</button></div>
+        <div><a href="{{name}}/stats/">stats</a></div>
+        <div id="stats"><stats-line name="{{name}}"></div>
       </template>
       <script>
        HTMLImports.whenReady(function () {
-           Polymer({
-               is: "service-button-row",
-               properties: {
-                   name: String,
-               },
-             ready: function() {
-             },
-               click: function() {
-                   window.open(this.name + '/', '_blank',
-                               'scrollbars=1,resizable=1,titlebar=0,location=0');
-               },
-             
-           });
+         Polymer({
+           is: "service-button-row",
+           properties: {
+             name: String,
+           },
+           ready: function() {
+           },
+           click: function() {
+             window.open(this.name + '/', '_blank',
+                         'scrollbars=1,resizable=1,titlebar=0,location=0');
+           },
+         });
        });
       </script>
     </dom-module>
@@ -78,7 +71,7 @@
       <hr>
       <service-button-row name="ascoltami"></service-button-row>
       <hr>
-      <service-button-row name="picamserve"></service-button-row>
+      <!--  <service-button-row name="picamserve"></service-button-row> -->  
       <service-button-row name="vidref"></service-button-row>
       <hr>
       <service-button-row name="collector"></service-button-row>
@@ -88,9 +81,10 @@
       <service-button-row name="timeline"></service-button-row>
       <service-button-row name="paint"></service-button-row>
       <service-button-row name="effectEval"></service-button-row>
-      <hr>
+<!--       <hr>
       <service-button-row name="subServer"></service-button-row>
       <service-button-row name="subComposer"></service-button-row>
+      -->
     </div>
     
   </body>
--- a/light9/web/stats-line.js	Thu Jun 06 09:31:36 2019 +0000
+++ b/light9/web/stats-line.js	Thu Jun 06 10:02:19 2019 +0000
@@ -23,7 +23,14 @@
                             resp.json().then((msg) => {
                                 this.stats = msg;
                                 setTimeout(reload, 1000);
+                            }).catch((err) => {
+                                setTimeout(reload, 1000);
                             });
+                        } else {
+                            if (resp.status == 502) {
+                                setTimeout(reload, 5000);
+                            }
+                            // 404: likely not mapped to a responding server
                         }
                     });
                 }
--- a/light9/web/stats-process.js	Thu Jun 06 09:31:36 2019 +0000
+++ b/light9/web/stats-process.js	Thu Jun 06 10:02:19 2019 +0000
@@ -37,7 +37,7 @@
             // wrong type of fade- never goes to 0
             ctx.fillStyle = '#00000003';
             ctx.fillRect(0, 0, w, h);
-            if (this.data.time < now - 2) {
+            if (!this.data || this.data.time < now - 2) {
                 return;
             }
             const dt = now - prev;