hydrabadger/run-node

49 lines
1.0 KiB
Plaintext
Executable File

#/bin/bash
# Starts a Hydrabadger node
# =========================
#
# Optional environment variables:
#
# * HYDRABADGER_LOG_ADDTL:
#
# Appends additional logging args (debug, trace, filters, etc.).
#
# * HYDRABADGER_RELEASE:
#
# Builds in debug mode if `HYDRABADGER_RELEASE` == `0` or `false`.
# Slows down output and makes reading log easier.
#
#
let HOST_ID=$1
let PEER_0_ID=$HOST_ID-1
let PEER_1_ID=$HOST_ID+1
printf -v HOST_PORT "3%03d" $HOST_ID
printf -v PEER_0_PORT "3%03d" $PEER_0_ID
printf -v PEER_1_PORT "3%03d" $PEER_1_ID
HYDRABADGER_LOG=peer_node::hydrabadger=error,warn,info,$HYDRABADGER_LOG_ADDTL
if [[ $HYDRABADGER_RELEASE ]]
then
case "$HYDRABADGER_RELEASE" in
0) RELEASE="" ;;
false) RELEASE="" ;;
*) RELEASE="--release" ;;
esac
else
RELEASE="--release"
fi
bash -c "\
HYDRABADGER_LOG=$HYDRABADGER_LOG cargo run --bin peer_node \
$RELEASE \
-- \
-b localhost:$HOST_PORT \
-r localhost:$PEER_0_PORT \
-r localhost:$PEER_1_PORT\
$2 $3 $4 $5 $6 $7 $8
"