aboutsummaryrefslogtreecommitdiffstats
path: root/watcher.sh
diff options
context:
space:
mode:
Diffstat (limited to 'watcher.sh')
-rwxr-xr-xwatcher.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/watcher.sh b/watcher.sh
index b900a50c..3fb60993 100755
--- a/watcher.sh
+++ b/watcher.sh
@@ -1,19 +1,20 @@
#!/bin/bash
sats=100000000
+threshold=$1
while true
do
ln=$(lncli --lnddir=/root/.lnda --network=mainnet --chain=bitcoin --rpcserver=localhost:10001 channelbalance | jr .balance)
bc=$(bitcoin-cli getbalance)
el=$(elements-cli getbalance | jr .bitcoin)
total=$(node -pe "$ln + $bc * $sats + $el * $sats")
- low=$(node -pe "$total < $1")
+ low=$(node -pe "$total < $threshold")
echo $(date -Is) ln $ln bc $bc el $el tot $total
if "$low"; then
- echo "Balance below threshold, shutting down"
- yarn pm2 stop 0 > /dev/null
- cd /root/mailgun && node index.js
- exit
+ echo "Threshold hit, setting new threshold"
+ threshold=$total
+ # yarn pm2 stop 0 > /dev/null
+ node /root/mailgun/index.js
fi
sleep 10
done