Skip to content

Commit

Permalink
Split code and data directories with season prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
platfowner committed Aug 23, 2024
1 parent 78b9c90 commit 3c4bc6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
16 changes: 8 additions & 8 deletions deploy_blockchain_genesis_onprem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ if [[ $KEEP_CODE_OPTION = "--no-keep-code" ]]; then
printf "NODE_TARGET_ADDR=${NODE_TARGET_ADDR}\n"

printf "\n* >> Deploying files for parent node $node_index (${NODE_TARGET_ADDR}) *********************************************************\n\n"
sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) scp -rv $FILES_FOR_NODE ${NODE_TARGET_ADDR}:~/ain-blockchain/
sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) scp -rv $FILES_FOR_NODE ${NODE_TARGET_ADDR}:~/${SEASON}-ain-blockchain/
done
fi
fi
Expand All @@ -281,7 +281,7 @@ if [[ $SETUP_OPTION = "--setup" ]]; then
printf "NODE_TARGET_ADDR=${NODE_TARGET_ADDR}\n"

printf "\n* >> Setting up parent node $node_index (${NODE_TARGET_ADDR}) *********************************************************\n\n"
echo ${NODE_LOGIN_PW} | sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) ssh -v ${NODE_TARGET_ADDR} "cd ./ain-blockchain; . setup_blockchain_ubuntu_onprem.sh"
echo ${NODE_LOGIN_PW} | sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) ssh -v ${NODE_TARGET_ADDR} "cd ./${SEASON}-ain-blockchain; . setup_blockchain_ubuntu_onprem.sh"
done
fi
fi
Expand All @@ -306,7 +306,7 @@ if [[ $KEEP_CODE_OPTION = "--no-keep-code" ]]; then
printf "NODE_TARGET_ADDR=${NODE_TARGET_ADDR}\n"

printf "\n* >> Installing node modules for parent node $node_index (${NODE_TARGET_ADDR}) *********************************************************\n\n"
sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) ssh -v ${NODE_TARGET_ADDR} "cd ./ain-blockchain; yarn install --ignore-engines"
sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) ssh -v ${NODE_TARGET_ADDR} "cd ./${SEASON}-ain-blockchain; yarn install --ignore-engines"
done
fi
fi
Expand Down Expand Up @@ -347,9 +347,9 @@ fi

printf "\nStarting blockchain servers...\n\n"
if [[ $KEEP_CODE_OPTION = "--no-keep-code" ]]; then
GO_TO_PROJECT_ROOT_CMD="cd ./ain-blockchain"
GO_TO_PROJECT_ROOT_CMD="cd ./${SEASON}-ain-blockchain"
else
GO_TO_PROJECT_ROOT_CMD="cd \$(find /home/ain-blockchain* -maxdepth 0 -type d)"
GO_TO_PROJECT_ROOT_CMD="cd \$(find /home/${SEASON}-ain-blockchain* -maxdepth 0 -type d)"
fi

#START_TRACKER_CMD_BASE="$GO_TO_PROJECT_ROOT_CMD && . start_tracker_genesis_gcp.sh"
Expand Down Expand Up @@ -384,9 +384,9 @@ if [[ $begin_index -le $PARENT_NODE_INDEX_END ]] && [[ $PARENT_NODE_INDEX_END -g
if [[ $KEEP_DATA_OPTION = "--no-keep-data" ]]; then
printf "\n* >> Removing old data for parent node $node_index (${NODE_TARGET_ADDR}) *********************************************************\n\n"

CHAINS_DIR=/home/ain_blockchain_data/chains
SNAPSHOTS_DIR=/home/ain_blockchain_data/snapshots
LOGS_DIR=/home/ain_blockchain_data/logs
CHAINS_DIR=/home/${SEASON}_ain_blockchain_data/chains
SNAPSHOTS_DIR=/home/${SEASON}_ain_blockchain_data/snapshots
LOGS_DIR=/home/${SEASON}_ain_blockchain_data/logs
echo ${NODE_LOGIN_PW} | sshpass -f <(printf '%s\n' ${NODE_LOGIN_PW}) ssh -v ${NODE_TARGET_ADDR} "sudo -S rm -rf $CHAINS_DIR $SNAPSHOTS_DIR $LOGS_DIR"
fi

Expand Down
21 changes: 12 additions & 9 deletions start_node_genesis_onprem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ sudo killall node
if [[ $KEEP_CODE_OPTION = "--no-keep-code" ]]; then
printf '\n'
printf 'Setting up new working directory..\n'
sudo rm -rf /home/ain-blockchain*
CODE_CMD="cd ~; sudo mv ain-blockchain /home; sudo chmod -R 777 /home/ain-blockchain; sudo chown -R $GCP_USER:$GCP_USER /home/ain-blockchain; cd /home/ain-blockchain"
sudo rm -rf /home/${SEASON}-ain-blockchain*
CODE_CMD="cd ~; sudo mv ${SEASON}-ain-blockchain /home; sudo chmod -R 777 /home/${SEASON}-ain-blockchain; sudo chown -R $GCP_USER:$GCP_USER /home/${SEASON}-ain-blockchain; cd /home/${SEASON}-ain-blockchain"
printf "\nCODE_CMD=$CODE_CMD\n"
eval $CODE_CMD
else
printf '\n'
printf 'Reusing existing working directory..\n'
OLD_DIR_PATH=$(find /home/ain-blockchain* -maxdepth 0 -type d)
OLD_DIR_PATH=$(find /home/${SEASON}-ain-blockchain* -maxdepth 0 -type d)
printf "OLD_DIR_PATH=$OLD_DIR_PATH\n"
CODE_CMD="sudo chmod -R 777 $OLD_DIR_PATH; sudo chown -R $GCP_USER:$GCP_USER $OLD_DIR_PATH"
printf "\nCODE_CMD=$CODE_CMD\n"
Expand All @@ -194,18 +194,18 @@ fi
if [[ $KEEP_DATA_OPTION = "--no-keep-data" ]]; then
printf '\n'
printf 'Setting up new data directory..\n'
sudo rm -rf /home/ain_blockchain_data/chains
sudo rm -rf /home/ain_blockchain_data/snapshots
sudo rm -rf /home/ain_blockchain_data/logs
DATA_CMD="sudo mkdir -p /home/ain_blockchain_data; sudo chmod -R 777 /home/ain_blockchain_data; sudo chown -R $GCP_USER:$GCP_USER /home/ain_blockchain_data"
sudo rm -rf /home/${SEASON}_ain_blockchain_data/chains
sudo rm -rf /home/${SEASON}_ain_blockchain_data/snapshots
sudo rm -rf /home/${SEASON}_ain_blockchain_data/logs
DATA_CMD="sudo mkdir -p /home/${SEASON}_ain_blockchain_data; sudo chmod -R 777 /home/${SEASON}_ain_blockchain_data; sudo chown -R $GCP_USER:$GCP_USER /home/${SEASON}_ain_blockchain_data"
printf "\nDATA_CMD=$DATA_CMD\n"
eval $DATA_CMD
else
printf 'Reusing existing data directory..\n'
if [[ $CHOWN_DATA_OPTION = "--no-chown-data" ]]; then
DATA_CMD="sudo mkdir -p /home/ain_blockchain_data; sudo chmod 777 /home/ain_blockchain_data; sudo chown $GCP_USER:$GCP_USER /home/ain_blockchain_data"
DATA_CMD="sudo mkdir -p /home/${SEASON}_ain_blockchain_data; sudo chmod 777 /home/${SEASON}_ain_blockchain_data; sudo chown $GCP_USER:$GCP_USER /home/${SEASON}_ain_blockchain_data"
else
DATA_CMD="sudo mkdir -p /home/ain_blockchain_data; sudo chmod -R 777 /home/ain_blockchain_data; sudo chown -R $GCP_USER:$GCP_USER /home/ain_blockchain_data"
DATA_CMD="sudo mkdir -p /home/${SEASON}_ain_blockchain_data; sudo chmod -R 777 /home/${SEASON}_ain_blockchain_data; sudo chown -R $GCP_USER:$GCP_USER /home/${SEASON}_ain_blockchain_data"
fi
printf "\nDATA_CMD=$DATA_CMD\n"
eval $DATA_CMD
Expand Down Expand Up @@ -327,6 +327,9 @@ printf "LOG_BANDAGE_INFO=$LOG_BANDAGE_INFO\n"
# on-premise nodes run with "comcom" hosting env
export HOSTING_ENV="comcom"
printf "HOSTING_ENV=$HOSTING_ENV\n"
# on-premise nodes run with a blockchain data directory prefixed by ${SEASON}_
export BLOCKCHAIN_DATA_DIR="/home/${SEASON}_ain_blockchain_data"
printf "BLOCKCHAIN_DATA_DIR=$BLOCKCHAIN_DATA_DIR\n"

if [[ "$SEASON" = "sandbox" ]]; then
MAX_OLD_SPACE_SIZE_MB=11000
Expand Down

0 comments on commit 3c4bc6d

Please sign in to comment.