Changeset - e0dd7fa987ea
[Not reviewed]
default
0 3 0
Drew Perttula - 6 years ago 2019-06-06 10:02:19
drewp@bigasterisk.com
stats: retry downed servers so their stats wake up when they do
Ignore-this: dbb695fd829292af2450065603cd8d7e
3 files changed with 29 insertions and 28 deletions:
0 comments (0 inline, 0 general)
light9/web/index.html
Show inline comments
 
@@ -5,16 +5,14 @@
 
    <meta charset="utf-8" />
 
    <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
 
    <link rel="stylesheet" href="/style.css">
 
    <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>
 
        <style>
 
         :host { padding-bottom: 10px;  }
 
         a {
 
@@ -38,60 +36,56 @@
 
         }
 
         :host > div { display: inline-block; vertical-align: top; }
 
         :host > div:nth-child(2) { width: 9em; }
 
         :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>
 
    
 
    <h1>light9 home page</h1>
 

	
 
    <div style="display: grid">
 
      <service-button-row name="rdfdb"></service-button-row>
 
      <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>
 
      <service-button-row name="effectSequencer"></service-button-row>
 
      <service-button-row name="live"></service-button-row>
 
      <service-button-row name="effects"></service-button-row>
 
      <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>
 
</html>
light9/web/stats-line.js
Show inline comments
 
@@ -20,13 +20,20 @@ class StatsLine extends LitElement {
 
                const reload = () => {
 
                    fetch(this.name + '/stats/?format=json').then((resp) => {
 
                        if (resp.ok) {
 
                            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
 
                        }
 
                    });
 
                }
 
                reload();
 
            }
 
        });
light9/web/stats-process.js
Show inline comments
 
@@ -34,13 +34,13 @@ class StatsProcess extends LitElement {
 

	
 
            const now = Date.now() / 1000;
 
            ctx.beginPath();
 
            // 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;
 
            prev = now;
 

	
 
            const size = remap(this.data.memMb, /*in*/ 20, 600, /*out*/ 3, 30);
0 comments (0 inline, 0 general)