Use unique log file for each additional (-x/-X) fullnodes

This commit is contained in:
Michael Vines 2019-01-22 07:39:10 -08:00 committed by Grimes
parent 3b0ca9f478
commit ae90ac238c

View File

@ -90,22 +90,25 @@ pids=()
logs=() logs=()
getNodeLogFile() { getNodeLogFile() {
declare cmd=$1 declare nodeIndex=$1
declare cmd=$2
declare baseCmd declare baseCmd
baseCmd=$(basename "${cmd// */}" .sh) baseCmd=$(basename "${cmd// */}" .sh)
echo "log-$baseCmd.txt" echo "log-$baseCmd-$nodeIndex.txt"
} }
startNode() { startNode() {
declare cmd=$1 declare nodeIndex=$1
declare cmd=$2
echo "--- Start $cmd" echo "--- Start $cmd"
declare log declare log
log=$(getNodeLogFile "$cmd") log=$(getNodeLogFile "$nodeIndex" "$cmd")
rm -f "$log" rm -f "$log"
$cmd > "$log" 2>&1 & $cmd > "$log" 2>&1 &
declare pid=$! declare pid=$!
pids+=("$pid") pids+=("$pid")
echo "pid: $pid" echo "pid: $pid"
echo "log: $log"
} }
startNodes() { startNodes() {
@ -113,10 +116,11 @@ startNodes() {
if [[ ${#logs[@]} -eq 0 ]]; then if [[ ${#logs[@]} -eq 0 ]]; then
addLogs=true addLogs=true
fi fi
for cmd in "${nodes[@]}"; do for i in $(seq 0 $((${#nodes[@]} - 1))); do
startNode "$cmd" declare cmd=${nodes[$i]}
startNode "$i" "$cmd"
if $addLogs; then if $addLogs; then
logs+=("$(getNodeLogFile "$cmd")") logs+=("$(getNodeLogFile "$i" "$cmd")")
fi fi
done done
} }
@ -167,7 +171,7 @@ rollingNodeRestart() {
# node that was just stopped # node that was just stopped
echo "(sleeping for 20 seconds)" echo "(sleeping for 20 seconds)"
sleep 20 sleep 20
startNode "$cmd" startNode "$i" "$cmd"
fi fi
done done