Last active
March 10, 2019 10:48
-
-
Save lukestokes/467045e2472b76d6c2388f193f9028c3 to your computer and use it in GitHub Desktop.
If the blocknumber isn't increasing, restart the deamon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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