From c28d1120f61f09676c492a887cde8878c4a20289 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20Martin-Leg=C3=A8ne?= <robert@nic.ar>
Date: Mon, 3 Dec 2018 01:51:33 -0300
Subject: [PATCH] Ignore errors when monitor.js can not connect. Also, use
 Date.now() correctly.

---
 bin/cron.sh    |  4 +---
 bin/monitor.js | 13 ++++++-------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/bin/cron.sh b/bin/cron.sh
index 50a0b0a..6710a96 100755
--- a/bin/cron.sh
+++ b/bin/cron.sh
@@ -1,10 +1,8 @@
 #!/bin/bash
 
 trap 'exit 1' ERR
-# Go $HOME
-cd
 # Log in home directory
-exec < /dev/null > bfa-cron-output.log 2>&1
+exec < /dev/null > ${HOME}/bfa-cron-output.log 2>&1
 # Go to script bin, 'cause we expect to find $BFAHOME/bin/env there
 cd `dirname $0`
 source ./env
diff --git a/bin/monitor.js b/bin/monitor.js
index 55a4492..609095b 100755
--- a/bin/monitor.js
+++ b/bin/monitor.js
@@ -101,7 +101,7 @@ function    peerlist()
         },
         function failedToGetAdminPeers(x)
         {
-            console.log( x );
+            // ignore connection problems?
         }
     );
 }
@@ -156,17 +156,15 @@ function    mayseal()
         function failedToGetIsMiningBool(x)
         {
             // Probably geth is not running.
-            console.log(x);
+            //console.log(x);
         }
     );
 }
 
 function    unlock()
 {
-    var         now                 =   new Date();
-    if ( lastUnlock + 600 > now )
+    if ( lastUnlock + 600 > Date.now() / 1000 )
         return;
-    lastUnlock = now;
     web3.eth.personal.bfalistWallets()
     .then(
         function pushone(x)
@@ -192,6 +190,7 @@ function    unlock()
                     promises.push( promise );
                 }
             }
+            lastUnlock = Date.now() / 1000;
         }
         ,
         function err(x)
@@ -208,5 +207,5 @@ function    timer()
     unlock();
 }
 
-peerlist();
-setInterval( timer, 60 * 1000 );
+setTimeout(  timer,      5 * 1000   );
+setInterval( timer,     60 * 1000   );
-- 
GitLab