Browse Source

service restart counter

master
Christian Rotzoll 6 years ago
parent
commit
8469e48199
  1. 8
      home.admin/80scanLND.sh
  2. 8
      home.admin/_bootstrap.sh
  3. 1
      home.admin/assets/bitcoind.service
  4. 1
      home.admin/assets/litecoind.service
  5. 1
      home.admin/assets/lnd.service
  6. 8
      home.admin/config.scripts/blitz.statusscan.sh
  7. 19
      home.admin/config.scripts/blitz.systemd.sh

8
home.admin/80scanLND.sh

@ -32,6 +32,10 @@ if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ]; then
echo "*****************************************"
echo "If you just started some config/setup, this might be OK."
echo
if [ ${startcountBlockchain} -gt 1 ]; then
echo "${startcountBlockchain} RESTARTS DETECTED - ${network}d might be in a error loop"
echo
fi
if [ ${#bitcoinErrorFull} -gt 0 ]; then
echo "More Error Detail:"
echo ${bitcoinErrorFull}
@ -73,6 +77,10 @@ elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ]; then
echo "*********************************"
echo "If you just started some config/setup, this might be OK."
echo
if [ ${startcountLightning} -gt 1 ]; then
echo "${startcountLightning} RESTARTS DETECTED - ${network}d might be in a error loop"
echo
fi
if [ ${#lndErrorFull} -gt 0 ]; then
echo "More Error Detail:"
echo ${lndErrorFull}

8
home.admin/_bootstrap.sh

@ -65,10 +65,10 @@ fi
sudo chmod 777 ${infoFile}
# resetting start count files
echo "SYSTEMD RESTART LOG: blockchain (bitcoind/litecoind)" > /home/admin/blockchain.systemd.log
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/lightning.systemd.log
sudo chmod 777 /home/admin/blockchain.systemd.log
sudo chmod 777 /home/admin/lightning.systemd.log
echo "SYSTEMD RESTART LOG: blockchain (bitcoind/litecoind)" > /home/admin/systemd.blockchain.log
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log
sudo chmod 777 /home/admin/systemd.blockchain.log
sudo chmod 777 /home/admin/systemd.lightning.log
# Emergency cleaning logs when over 1GB (to prevent SD card filling up)
# see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944

1
home.admin/assets/bitcoind.service

@ -13,6 +13,7 @@ User=bitcoin
Group=bitcoin
Type=forking
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid
KillMode=process
Restart=always

1
home.admin/assets/litecoind.service

@ -10,6 +10,7 @@ After=bootstrap.service
User=bitcoin
Group=bitcoin
Type=simple
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf
KillMode=process
Restart=always

1
home.admin/assets/lnd.service

@ -10,6 +10,7 @@ After=bitcoind.service
[Service]
EnvironmentFile=/mnt/hdd/raspiblitz.conf
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log lightning STARTED
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}:${lndPort}
PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin

8
home.admin/config.scripts/blitz.statusscan.sh

@ -28,6 +28,14 @@ echo "tempCelsius='${tempC}'"
uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime)
echo "uptime=${uptime}"
# count restarts of bitcoind/litecoind
startcountBlockchain=$(cat systemd.blockchain.log | grep -c "STARTED")
echo "startcountBlockchain=${startcountBlockchain}"
# count restarts of bitcoind/litecoind
startcountLightning=$(cat systemd.lightning.log | grep -c "STARTED")
echo "startcountLightning=${startcountLightning}"
# is bitcoind running
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
echo "bitcoinActive=${bitcoinRunning}"

19
home.admin/config.scripts/blitz.systemd.sh

@ -0,0 +1,19 @@
#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "additional systemd services"
echo "blitz.systemd.sh log blockchain STARTED"
echo "blitz.systemd.sh log loghtning STARTED"
exit 1
fi
# check parameter
if [ "${1}" != "log" ]; then
echo "# FAIL: unkown parameter"
fi
# writing log file entry
logFile="/home/admin/systemd.${2}.log"
echo "${3} $(date +%s)" >> ${logFile}
echo "# OK: log '${3}' written to ${logFile}"
Loading…
Cancel
Save