Skip to content

Instantly share code, notes, and snippets.

@lukestokes
Last active March 10, 2019 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lukestokes/467045e2472b76d6c2388f193f9028c3 to your computer and use it in GitHub Desktop.
Save lukestokes/467045e2472b76d6c2388f193f9028c3 to your computer and use it in GitHub Desktop.
If the blocknumber isn't increasing, restart the deamon.
#!/bin/bash
# checkdaemon.sh
# Make sure the daemon is not stuck.
# Add the following to the crontab (i.e. crontab -e)
# */30 * * * * ~/smartcash/checkdaemons.sh
PREFIX="0"
START_NUMBER=$(<~/smartcash/start_number.txt)
END_NUMBER=$(<~/smartcash/end_number.txt)
for (( number=$START_NUMBER; number<=$END_NUMBER; number++ ))
do
if [ $number -gt 9 ]
then
PREFIX=""
fi
NODE=$PREFIX$number
previousBlock=$(<~/smartcash/SmartNode$NODE/blockcount)
currentBlock=$(~/smartcash/smart-cli.sh $NODE getblockcount)
~/smartcash/smart-cli.sh $NODE getblockcount > ~/smartcash/SmartNode$NODE/blockcount
if [ "$previousBlock" == "$currentBlock" ]; then
echo "Restarting Node $NODE on $(date)" >> ~/smartcash/SmartNode$NODE/auto_restarts.txt
~/smartcash/smart-cli.sh $NODE stop
sleep 10
~/smartcash/smart-start.sh $NODE
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment