optimize shell script

This commit is contained in:
wanwiset25 2024-12-30 20:44:01 -05:00
parent 654be4d874
commit 0404803366

View file

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
set -eo pipefail
if [ ! -d /work/xdcchain/XDC/chaindata ] if [ ! -d /work/xdcchain/XDC/chaindata ]
then then
if test -z "$PRIVATE_KEY" if test -z "$PRIVATE_KEY"
@ -25,41 +27,13 @@ do
fi fi
done < "$input" done < "$input"
log_level=3 log_level="${LOG_LEVEL:-3}"
if test -z "$LOG_LEVEL"
then
echo "Log level not set, default to verbosity of $log_level"
else
echo "Log level found, set to $LOG_LEVEL"
log_level=$LOG_LEVEL
fi
port=30303 port="${PORT:-30303}"
if test -z "$PORT"
then
echo "PORT not set, default to $port"
else
echo "PORT found, set to $PORT"
port=$PORT
fi
rpc_port=8545 rpc_port="${RPC_PORT:-8545}"
if test -z "$RPC_PORT"
then
echo "RPC_PORT not set, default to $rpc_port"
else
echo "RPC_PORT found, set to $RPC_PORT"
rpc_port=$RPC_PORT
fi
ws_port=8555 ws_port="${WS_PORT:-8555}"
if test -z "$WS_PORT"
then
echo "WS_PORT not set, default to $ws_port"
else
echo "WS_PORT found, set to $WS_PORT"
ws_port=$WS_PORT
fi
netstats="${NODE_NAME}-${wallet}:xinfin_xdpos_hybrid_network_stats@devnetstats.apothem.network:2000" netstats="${NODE_NAME}-${wallet}:xinfin_xdpos_hybrid_network_stats@devnetstats.apothem.network:2000"
@ -70,14 +44,24 @@ echo "Starting nodes with $bootnodes ..."
# Note: --gcmode=archive means node will store all historical data. This will lead to high memory usage. But sync mode require archive to sync # Note: --gcmode=archive means node will store all historical data. This will lead to high memory usage. But sync mode require archive to sync
# https://github.com/XinFinOrg/XDPoSChain/issues/268 # https://github.com/XinFinOrg/XDPoSChain/issues/268
XDC --ethstats ${netstats} --gcmode archive \ XDC --ethstats ${netstats} \
--bootnodes ${bootnodes} --syncmode full \ --gcmode archive \
--datadir /work/xdcchain --networkid 551 \ --bootnodes ${bootnodes} \
-port $port --rpc --rpccorsdomain "*" --rpcaddr 0.0.0.0 \ --syncmode full \
--datadir /work/xdcchain \
--networkid 551 \
-port $port \
--rpc --rpccorsdomain "*" \
--rpcaddr 0.0.0.0 \
--rpcport $rpc_port \ --rpcport $rpc_port \
--rpcapi db,eth,debug,net,shh,txpool,personal,web3,XDPoS \ --rpcapi db,eth,debug,net,shh,txpool,personal,web3,XDPoS \
--rpcvhosts "*" --unlock "${wallet}" --password /work/.pwd --mine \ --rpcvhosts "*" \
--gasprice "1" --targetgaslimit "420000000" --verbosity ${log_level} \ --unlock "${wallet}" \
--password /work/.pwd --mine \
--gasprice "1" --targetgaslimit "420000000" \
--verbosity ${log_level} \
--debugdatadir /work/xdcchain \ --debugdatadir /work/xdcchain \
--ws --wsaddr=0.0.0.0 --wsport $ws_port \ --ws \
--wsaddr=0.0.0.0 \
--wsport $ws_port \
--wsorigins "*" 2>&1 >>/work/xdcchain/xdc.log | tee -a /work/xdcchain/xdc.log --wsorigins "*" 2>&1 >>/work/xdcchain/xdc.log | tee -a /work/xdcchain/xdc.log