Skip to content

Instantly share code, notes, and snippets.

@tarrenj
Last active February 13, 2018 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarrenj/004c781dbe625b23395ea6e8eda5d10e to your computer and use it in GitHub Desktop.
Save tarrenj/004c781dbe625b23395ea6e8eda5d10e to your computer and use it in GitHub Desktop.
(Bad) bash script to start and stop zend a bunch of times
#!/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