Skip to content
Snippets Groups Projects
Commit af2c7fb7 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Fate-sharing process control

parent c1cd5d6b
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,20 @@ bootnodekeyfile=${BFANETWORKDIR}/bootnode/key
# Bail out if anything fails.
trap "exit 1" ERR
unset LOGDIR LOGPIPE PIDIDX
declare -A PIDIDX
function reaper()
{
local rc
for pid in ${!PIDIDX[*]}
do
kill -0 $pid 2>/dev/null && continue
rc=wait $pid
echo "${PIDIDX[$pid]} (pid $pid) has exited with value $rc"
unset aaa[$pid]
done
}
if [ "$VIRTUALIZATION" = "DOCKER" ]
then
......@@ -47,35 +61,40 @@ then
echo "or: docker exec -i bfanode bfalog.sh"
fi
unset LOGDIR LOGPIPE PIDLIST
echo "*** Setting up logging."
# Clean up logging
LOGDIR=$( mktemp -d )
trap "rm -f ${LOGDIR}" EXIT
trap "rm -rf ${LOGDIR}" EXIT
LOGPIPE=${LOGDIR}/logpipe
mknod ${LOGPIPE} p
${BFAHOME}/bin/log.sh ${BFANODEDIR}/log < ${LOGPIPE} &
PIDLIST="${PIDLIST} $!"
PIDIDX[$!]="log.sh"
echo "*** Starting geth."
geth --config ${BFATOML} --gcmode archive --verbosity ${BFAVERBOSITY:-3} --allow-insecure-unlock > ${LOGPIPE} 2>&1 &
PIDLIST="${PIDLIST} $!"
PIDIDX[$!]="geth"
# bootnode
if [ -r "$bootnodekeyfile" ]
then
echo "*** Starting bootnode."
bootnode --nodekey $bootnodekeyfile &
PIDLIST="${PIDLIST} $!"
bootnode --nodekey $bootnodekeyfile > ${LOGPIPE} 2>&1 &
PIDIDX[$!]="bootnode"
fi
echo "*** Starting monitor.js"
monitor.js &
PIDLIST="${PIDLIST} $!"
monitor.js > ${LOGPIPE} 2>&1 &
PIDIDX[$!]="monitor.js"
wait -n # if one dies
echo "*** Some process ended, so will shut down other processes too." > ${LOGPIPE}
sleep 2 # give log.sh time to work on the data written, before we kill it.
kill ${PIDLIST} # kill all
wait # wait for them all to end
echo "*** Some process ended, so will shut down other processes too." > ${LOGPIPE}
kill ${!PIDIDX[*]} 2>/dev/null || true # kill all
# wait for them all to end
max=30
while [ -n "${!PIDIDX[*]}" -a $max -gt 0 ]
do
sleep 1
max=$(( $max - 1 ))
done
kill -KILL ${!PIDIDX[*]} 2>/dev/null || true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment