Skip to content

Commit

Permalink
refactor: making entry.sh more generic for k8s, etc (MystenLabs#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
allan-bailey authored Jul 15, 2022
1 parent ec7592e commit 94b6b2c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions narwhal/Docker/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ fi

# Environment variables to use on the script
NODE_BIN="./bin/node"
KEYS_PATH="/validators/validator-$VALIDATOR_ID/key.json"
COMMITTEE_PATH="/validators/committee.json"
PARAMETERS_PATH="/validators/parameters.json"
KEYS_PATH=${KEYS_PATH:="/validators/validator-$VALIDATOR_ID/key.json"}
COMMITTEE_PATH=${COMMITTEE_PATH:="/validators/committee.json"}
PARAMETERS_PATH=${PARAMETERS_PATH:="/validators/parameters.json"}
DATA_PATH=${DATA_PATH:="/validators"}

if [[ "$CLEANUP_DISABLED" = "true" ]]; then
echo "Will not clean up existing directories..."
else
if [[ "$NODE_TYPE" = "primary" ]]; then
# Clean up only the primary node's data
rm -r "/validators/validator-$VALIDATOR_ID/db-primary"
rm -r "${DATA_PATH}/validator-$VALIDATOR_ID/db-primary"
elif [[ "$NODE_TYPE" = "worker" ]]; then
# Clean up only the specific worker's node data
rm -r "/validators/validator-$VALIDATOR_ID/db-worker-${WORKER_ID}"
rm -r "${DATA_PATH}/validator-$VALIDATOR_ID/db-worker-${WORKER_ID}"
fi
fi

Expand All @@ -36,7 +37,7 @@ if [[ "$NODE_TYPE" = "primary" ]]; then
$NODE_BIN $LOG_LEVEL run \
--keys $KEYS_PATH \
--committee $COMMITTEE_PATH \
--store "/validators/validator-$VALIDATOR_ID/db-primary" \
--store "${DATA_PATH}/validator-$VALIDATOR_ID/db-primary" \
--parameters $PARAMETERS_PATH \
primary $CONSENSUS_DISABLED
elif [[ "$NODE_TYPE" = "worker" ]]; then
Expand All @@ -45,7 +46,7 @@ elif [[ "$NODE_TYPE" = "worker" ]]; then
$NODE_BIN $LOG_LEVEL run \
--keys $KEYS_PATH \
--committee $COMMITTEE_PATH \
--store "/validators/validator-$VALIDATOR_ID/db-worker-$WORKER_ID" \
--store "${DATA_PATH}/validator-$VALIDATOR_ID/db-worker-$WORKER_ID" \
--parameters $PARAMETERS_PATH \
worker --id $WORKER_ID
else
Expand Down

0 comments on commit 94b6b2c

Please sign in to comment.