Last active
February 13, 2018 05:44
-
-
Save tarrenj/004c781dbe625b23395ea6e8eda5d10e to your computer and use it in GitHub Desktop.
(Bad) bash script to start and stop zend a bunch of times
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
#!/usr/bin/env bash | |
SLEEPY=30 | |
ZEND="/home/smrtz/Builds/zen/src/zend --datadir=/home/smrtz/zen_test_datadir" | |
ZENCLI="/home/smrtz/Builds/zen/src/zen-cli --datadir=/home/smrtz/zen_test_datadir" | |
TESTNUM=60 | |
for I in {0..$TESTNUM}; do | |
echo "TEST NUMBER: "$I | |
# Start zend and grab PID | |
$ZEND && sleep 0.5 && ZEN_PID=$(cat /home/smrtz/zen_test_datadir/zend.pid) | |
echo "ZEN_PID: " $ZEN_PID | |
# Make sure zend is ready | |
while true; do | |
if $ZENCLI getinfo 2> /dev/null | grep -q "connections"; then | |
echo "zend ready, sleeping for "$SLEEPY"s" | |
break | |
fi | |
done | |
# Sleep, then print new block height | |
sleep $SLEEPY | |
$ZENCLI getchaintips | grep height | |
# Stop zend, unlock PID if it's failed for 5 seconds... | |
$ZENCLI stop | |
VAR=0 | |
while true; do | |
if ! ps -p $ZEN_PID > /dev/null; then | |
sync | |
sync | |
break | |
else | |
sleep .5 | |
((VAR++)) | |
if [ VAR \> 10 ]; then | |
kill -9 $ZEN_PID | |
fi | |
fi | |
done | |
sleep 0.5 | |
# Close for loop | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment