diff --git a/bin/start.sh b/bin/start.sh index e37a4522c2e1783cc99723e82048ec88c505d950..182bedb46d3c31fd4a55603b557fece2d4ecbcb3 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -34,21 +34,23 @@ function startbootnode echo "A bootnode is already running." false ) || exit - echo ${BASHPID} > ${BFANETWORKDIR}/start-bootnode-loop.pid if [ -t 1 ] then echo Starting bootnode. fi - while : - do - echo - echo '***' - echo - bootnode --nodekey $keyfile & - echo $! > $pidfile - wait - sleep 60 - done 2>&1 | ${BFAHOME}/bin/log.sh ${BFANETWORKDIR}/bootnode/log & + ( + echo ${BASHPID} > ${BFANETWORKDIR}/start-bootnode-loop.pid + while : + do + echo + echo '***' + echo + bootnode --nodekey $keyfile & + echo $! > $pidfile + wait + sleep 60 + done + ) 2>&1 | ${BFAHOME}/bin/log.sh ${BFANETWORKDIR}/bootnode/log & ) 9>> $pidfile } @@ -66,8 +68,8 @@ function startmonitor echo "A monitor is already running." false ) || exit - echo ${BASHPID} > ${BFANETWORKDIR}/start-monitor-loop.pid ( + echo ${BASHPID} > ${BFANETWORKDIR}/start-monitor-loop.pid while : do monitor.js & @@ -119,6 +121,53 @@ function geth_capab fi } +function geth_args +{ + # (re)configure parameters (you never know if they changed) + flexargs="$( getsyncmode )" + geth_capab + xtra=$( extradata ) + if [ -n "$xtra" ] + then + flexargs="${flexargs} --extradata $( extradata )" + fi + unset xtra + # + if [ "$netport" != 30303 ] + then + flexargs="${flexargs} --port $netport" + fi + if [ "$rpcport" != 30303 ] + then + flexargs="${flexargs} --rpcport $rpcport" + fi + if [ -n "$BFAVERBOSITY" -a "$BFAVERBOSITY" != 3 ] + then + flexargs="${flexargs} --verbosity ${BFAVERBOSITY:-3}" + fi + # the basic modules + rpcapis="eth,net,web3,clique" + if [ -e "${BFANODEDIR}/opentx" ] + then + # If you want other hostnames, put them in this file (comma separated) + read txhostnames dummy < ${BFANODEDIR}/opentx + if [ "${txhostnames}" = "" ] + then + # but if you don't put any hostnames, these are the defaults + txhostnames="localhost,opentx.bfa.ar" + fi + flexargs="${flexargs} --rpcvhosts ${txhostnames}" + # INADDR_ANY - listen on all addresses + flexargs="${flexargs} --rpcaddr 0.0.0.0" + # Oh, and don't put your keys in / because we use that as a dummy directory + flexargs="${flexargs} --keystore /" + else + # expose more modules, if we are a private node (localhost'ed) + rpcapis="${rpcapis},admin,miner,personal" + fi + flexargs="${flexargs} --rpcapi ${rpcapis}" +} + function startgeth { # Start the node. @@ -131,7 +180,6 @@ function startgeth echo "A geth is already running." false ) || exit 1 - echo ${BASHPID} > ${BFANETWORKDIR}/start-geth-loop.pid if [ -t 1 ] then echo Starting geth @@ -139,74 +187,34 @@ function startgeth echo Consider running: bfalog.sh fi loop_counter=0 - while : - do - loop_counter=$(( ${loop_counter} + 1 )) - ERRTEXT="geth" - echo - echo '***' - echo "*** loop #${loop_counter}" - echo '***' - echo - # (re)configure parameters (you never know if they changed) - flexargs="$( getsyncmode )" - geth_capab - # - xtra=$( extradata ) - if [ -n "$xtra" ] - then - flexargs="${flexargs} --extradata $( extradata )" - fi - unset xtra - # - if [ "$netport" != 30303 ] - then - flexargs="${flexargs} --port $netport" - fi - if [ "$rpcport" != 30303 ] - then - flexargs="${flexargs} --rpcport $rpcport" - fi - if [ -n "$BFAVERBOSITY" -a "$BFAVERBOSITY" != 3 ] - then - flexargs="${flexargs} --verbosity ${BFAVERBOSITY:-3}" - fi - # the basic modules - rpcapis="eth,net,web3,clique" - if [ -e "${BFANODEDIR}/opentx" ] - then - # If you want other hostnames, put them in this file (comma separated) - read txhostnames dummy < ${BFANODEDIR}/opentx - if [ "${txhostnames}" = "" ] - then - # but if you don't put any hostnames, these are the defaults - txhostnames="localhost,opentx.bfa.ar" - fi - flexargs="${flexargs} --rpcvhosts ${txhostnames}" - # INADDR_ANY - listen on all addresses - flexargs="${flexargs} --rpcaddr 0.0.0.0" - # Oh, and don't put your keys in / because we use that as a dummy directory - flexargs="${flexargs} --keystore /" - else - # expose more modules, if we are a private node (localhost'ed) - rpcapis="${rpcapis},admin,miner,personal" - fi - flexargs="${flexargs} --rpcapi ${rpcapis}" - set -x - geth \ - --datadir ${BFANODEDIR} \ - --networkid ${BFANETWORKID} \ - --rpc \ - --gcmode archive \ - ${flexargs} \ - --rpccorsdomain \* \ - --bootnodes "${bootnodes}" & - set +x - echo $! > $pidfile - rv=0 - wait -n || rv=$? - sleep 60 - done 2>&1 | ${BFAHOME}/bin/log.sh ${BFANODEDIR}/log & + ( + echo ${BASHPID} > ${BFANETWORKDIR}/start-geth-loop.pid + while : + do + loop_counter=$(( ${loop_counter} + 1 )) + ERRTEXT="geth" + echo + echo '***' + echo "*** loop #${loop_counter}" + echo '***' + echo + geth_args + set -x + geth \ + --datadir ${BFANODEDIR} \ + --networkid ${BFANETWORKID} \ + --rpc \ + --gcmode archive \ + ${flexargs} \ + --rpccorsdomain \* \ + --bootnodes "${bootnodes}" & + set +x + echo $! > $pidfile + rv=0 + wait -n || rv=$? + sleep 60 + done + ) 2>&1 | ${BFAHOME}/bin/log.sh ${BFANODEDIR}/log & ) 9>> $pidfile }