Add Tmux support for the local network sim
To use tmux, just set the USE_TMUX env variable to 'yes' or '1'
This commit is contained in:
parent
3efbe36c30
commit
84c238ca8b
|
@ -65,10 +65,17 @@ if [ -f "${MASTER_NODE_ADDRESS_FILE}" ]; then
|
|||
rm "${MASTER_NODE_ADDRESS_FILE}"
|
||||
fi
|
||||
|
||||
# multitail support
|
||||
MULTITAIL="${MULTITAIL:-multitail}" # to allow overriding the program name
|
||||
USE_MULTITAIL="${USE_MULTITAIL:-no}" # make it an opt-in
|
||||
type "$MULTITAIL" &>/dev/null || USE_MULTITAIL="no"
|
||||
# to allow overriding the program names
|
||||
MULTITAIL="${MULTITAIL:-multitail}"
|
||||
TMUX="${TMUX:-tmux}"
|
||||
TMUX_SESSION_NAME="${TMUX_SESSION_NAME:-nbc-network-sim}"
|
||||
|
||||
# Using tmux or multitail is an opt-in
|
||||
USE_MULTITAIL="${USE_MULTITAIL:-no}"
|
||||
type "$MULTITAIL" &>/dev/null || { echo $MULTITAIL is missing; USE_MULTITAIL="no"; }
|
||||
|
||||
USE_TMUX="${USE_TMUX:-no}"
|
||||
type "$TMUX" &>/dev/null || { echo $TMUX is missing; USE_TMUX="no"; }
|
||||
|
||||
# Prometheus config (continued inside the loop)
|
||||
mkdir -p "${METRICS_DIR}"
|
||||
|
@ -103,6 +110,13 @@ fi
|
|||
|
||||
COMMANDS=()
|
||||
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX new-session -s $TMUX_SESSION_NAME -d
|
||||
# maybe these should be moved to a user config file
|
||||
$TMUX set-option -t $TMUX_SESSION_NAME history-limit 999999
|
||||
$TMUX set -t $TMUX_SESSION_NAME mouse on
|
||||
fi
|
||||
|
||||
for i in $(seq $MASTER_NODE -1 $TOTAL_USER_NODES); do
|
||||
if [[ "$i" != "$MASTER_NODE" && "$USE_MULTITAIL" == "no" ]]; then
|
||||
# Wait for the master node to write out its address file
|
||||
|
@ -113,7 +127,10 @@ for i in $(seq $MASTER_NODE -1 $TOTAL_USER_NODES); do
|
|||
|
||||
CMD="${SIM_ROOT}/run_node.sh $i"
|
||||
|
||||
if [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX split-window -t $TMUX_SESSION_NAME "$CMD; pause"
|
||||
$TMUX select-layout -t $TMUX_SESSION_NAME tiled
|
||||
elif [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
if [[ "$i" == "$MASTER_NODE" ]]; then
|
||||
SLEEP="0"
|
||||
else
|
||||
|
@ -133,7 +150,11 @@ for i in $(seq $MASTER_NODE -1 $TOTAL_USER_NODES); do
|
|||
EOF
|
||||
done
|
||||
|
||||
if [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
if [[ "$USE_TMUX" != "no" ]]; then
|
||||
$TMUX kill-pane -t $TMUX_SESSION_NAME:0.0
|
||||
$TMUX select-layout -t $TMUX_SESSION_NAME tiled
|
||||
$TMUX attach-session -t $TMUX_SESSION_NAME -d
|
||||
elif [[ "$USE_MULTITAIL" != "no" ]]; then
|
||||
eval $MULTITAIL -s 3 -M 0 -x \"Nimbus beacon chain\" "${COMMANDS[@]}"
|
||||
else
|
||||
wait # Stop when all nodes have gone down
|
||||
|
|
Loading…
Reference in New Issue