Skip to content

Commit

Permalink
update the testnet.template and tn_up/down scripts for EOSIO#2111
Browse files Browse the repository at this point in the history
  • Loading branch information
pmesnier committed Apr 4, 2018
1 parent a501237 commit 6e8f9ce
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ programs/eosioc/eosioc
programs/launcher/launcher
programs/eosio-abigen/eosio-abigen

scripts/tn_init.sh

tests/app_test
tests/chain_bench
tests/chain_test
Expand Down
54 changes: 8 additions & 46 deletions scripts/eosio-tn_down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,20 @@ if [ "$PWD" != "$EOSIO_HOME" ]; then
exit -1
fi

prog=""
RD=""
for p in eosd eosiod nodeos; do
prog=$p
RD=bin
if [ -f $RD/$prog ]; then
break;
else
RD=programs/$prog
if [ -f $RD/$prog ]; then
break;
fi
fi
prog=""
RD=""
done

if [ \( -z "$prog" \) -o \( -z "RD" \) ]; then
echo unable to locate binary for eosd or eosiod or nodeos
exit 1
fi
prog=nodeos

if [ -z "$EOSIO_TN_RESTART_DATA_DIR" ]; then
echo data directory not set
exit 1
fi

DD=$EOSIO_TN_RESTART_DATA_DIR;
runtest=""
if [ $DD = "all" ]; then
runtest=$prog
else
runtest=`cat $DD/$prog.pid`
fi
echo runtest = $runtest
DD=var/lib/node_$EOSIO_NODE
runtest=`cat $DD/$prog.pid`
echo runtest = $runtest
running=`ps -e | grep $runtest | grep -cv grep `

if [ $running -ne 0 ]; then
echo killing $prog

if [ $runtest = $prog ]; then
pkill -15 $runtest
else
kill -15 $runtest
fi
pkill -15 $prog

for (( a = 10; $a; a = $(($a - 1)) )); do
echo waiting for safe termination, pass $((11 - $a))
for (( a = 1;11-$a; a = $(($a + 1)) )); do
echo waiting for safe termination, pass $a
sleep 2
running=`ps -e | grep $runtest | grep -cv grep`
echo running = $running
Expand All @@ -69,9 +35,5 @@ fi

if [ $running -ne 0 ]; then
echo killing $prog with SIGTERM failed, trying with SIGKILL
if [ $runtest = $prog ]; then
pkill -9 $runtest
else
kill -9 $runtest
fi
pkill -9 $runtest
fi
29 changes: 15 additions & 14 deletions scripts/eosio-tn_up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,39 @@ if [ -z "$EOSIO_NODE" ]; then
exit -1
fi

datadir=var/lib/node_$EOSIO_NODE
now=`date +'%Y_%m_%d_%H_%M_%S'`
log=stderr.$now.txt
touch $datadir/$log
rm $datadir/stderr.txt
ln -s $log $datadir/stderr.txt

relaunch() {
nohup $rundir/$prog $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $log &
echo "$rundir/$prog $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $datadir/$log "
nohup $rundir/$prog $* --data-dir $datadir --config-dir etc/eosio/node_$EOSIO_NODE > $datadir/stdout.txt 2>> $datadir/$log &
pid=$!

echo pid = $pid
echo $pid > $datadir/$prog.pid

for (( a = 10; $a; a = $(($a - 1)) )); do
echo checking viability pass $((11 - $a))
sleep 2
running=`ps -hp $pid`
running=$(pgrep $prog | grep -c $pid)
echo running = $running
if [ -z "$running" ]; then
break;
fi
connected=`grep -c "net_plugin.cpp:.*connection" $log`
connected=`grep -c "net_plugin.cpp:.*connection" $datadir/$log`
if [ "$connected" -ne 0 ]; then
break;
fi
done
}

datadir=var/lib/node_$EOSIO_NODE
now=`date +'%Y_%m_%d_%H_%M_%S'`
log=stderr.$now.txt
touch $datadir/$log
rm $datadir/stderr.txt
ln -s $log $datadir/stderr.txt


if [ -z "$EOSIO_LEVEL" ]; then
echo starting with no modifiers
relaunch $prog $rundir $*
if [ \( -z "$running" \) -o \( "$connected" -eq 0 \) ]; then
if [ "$connected" -eq 0 ]; then
EOSIO_LEVEL=replay
else
exit 0
Expand All @@ -66,7 +67,7 @@ fi
if [ "$EOSIO_LEVEL" == replay ]; then
echo starting with replay
relaunch $prog $rundir $* --replay
if [ \( -z "$running" \) -o \( "$connected" -eq 0 \) ]; then
if [ "$connected" -eq 0 ]; then
EOSIO_LEVEL=resync
else
exit 0
Expand Down
6 changes: 3 additions & 3 deletions testnet.template
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ wcmd create -n ignition
###INSERT cacmd


ecmd set contract eosio contracts/eosio.bios/eosio.bios.wast contracts/eosio.bios/eosio.bios.abi
ecmd set contract eosio contracts/eosio.bios contracts/eosio.bios/eosio.bios.wast contracts/eosio.bios/eosio.bios.abi

#the setprods.json argument cannot pass through the function call due to embedded quotes
echo ===== Start: $step ============ >> $logfile
Expand All @@ -95,7 +95,7 @@ programs/cleos/cleos --wallet-port $wdport --wallet-host $wdhost -p $biosport -H
echo ==== End: $step ============== >> $logfile
step=$(($step + 1))

ecmd set contract eosio contracts/eosio.system/eosio.system.wast contracts/eosio.system/eosio.system.abi
ecmd set contract eosio contracts/eosio.system contracts/eosio.system/eosio.system.wast contracts/eosio.system/eosio.system.abi

echo ===== Start: $step ============ >> $logfile
echo executing: cleos --wallet-port $wdport -p $biosport -H $bioshost push action eosio issue '{"to":"eosio","quantity":"1000000000.0000 EOS","memo":"init"}' -p eosio@active | tee -a $logfile
Expand All @@ -104,6 +104,6 @@ programs/cleos/cleos --wallet-port $wdport --wallet-host $wdhost -p $biosport -H
echo ==== End: $step ============== >> $logfile
step=$(($step + 1))

for a in {a..u}; do ecmd transfer eosio init$a 1000000.0000 "\"fund producer init$a\""; done
for a in {a..u}; do ecmd transfer eosio init$a 1000000.0000 "\"fund_producer_init$a\""; done

pkill -15 keosd

0 comments on commit 6e8f9ce

Please sign in to comment.