Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brishtiteveja/497471241d3a749a36416cdb99398f9e to your computer and use it in GitHub Desktop.
Save brishtiteveja/497471241d3a749a36416cdb99398f9e to your computer and use it in GitHub Desktop.
Auto kill restart of dtube test node
#!/bin/bash⏎
second=1⏎
csec=30⏎
sleep_time=$(( $second * $csec ))⏎
# rename script names so that it does not interfere with main node when you kill or restart
scritpt_name_to_kill_1='scripts/start_testnet'
scritpt_name_to_kill_2='scripts/main_testnet'
cnt=1⏎
while true⏎
do⏎
echo ""⏎
echo "Restarting dtube test node"⏎
echo ""⏎
time=`date`⏎
echo "Run No. "$cnt" @ "$time⏎
echo "**************************"⏎
echo "Stopping running dtube node. pid = "$pid⏎
ps aux | grep -v grep | grep $script_name_to_kill_1 | tr -s ' ' | cut -d ' ' -f 2 | xargs kill -9⏎
ps aux | grep -v grep | grep $script_name_to_kill_2 | tr -s ' ' | cut -d ' ' -f 2 | xargs kill -9⏎
./scripts/start_testnet.sh >> avalon_testnet.log 2>&1 &⏎
sleep 5⏎
curl localhost:3010/mineBlock⏎
sleep $sleep_time⏎
cnt=$(( $cnt + 1 ))⏎
done⏎
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment