Skip to content

Commit

Permalink
Merge pull request #1327 from ainblockchain/feature/platfowner/feature
Browse files Browse the repository at this point in the history
Update blockchain monitoring deploy scripts for onprem hosting
  • Loading branch information
platfowner authored Sep 13, 2024
2 parents 6e6ffdb + eb13600 commit 8e45715
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
31 changes: 23 additions & 8 deletions deploy_monitoring_gcp.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/bash

if [[ "$#" -lt 1 ]]; then
printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [--setup]\n"
printf "Example: bash deploy_monitoring_gcp.sh dev --setup\n"
printf "Example: bash deploy_monitoring_gcp.sh dev\n"
function usage() {
printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem} [--setup]\n"
printf "Example: bash deploy_monitoring_gcp.sh staging gcp \n"
printf "Example: bash deploy_monitoring_gcp.sh staging gcp --setup\n"
printf "Example: bash deploy_monitoring_gcp.sh staging onprem \n"
printf "Example: bash deploy_monitoring_gcp.sh staging onprem --setup\n"
printf "\n"
exit
}

if [[ $# -lt 2 ]] || [[ $# -gt 3 ]]; then
usage
fi

printf "\n[[[[[ deploy_monitoring_gcp.sh ]]]]]\n\n"

if [[ "$1" = 'dev' ]] || [[ "$1" = 'staging' ]] || [[ "$1" = 'sandbox' ]] || [[ "$1" = 'exp' ]] || [[ "$1" = 'spring' ]] || [[ "$1" = 'summer' ]] || [[ "$1" = 'mainnet' ]]; then
Expand All @@ -25,12 +32,20 @@ fi
printf "SEASON=$SEASON\n"
printf "PROJECT_ID=$PROJECT_ID\n"

GCP_USER="runner"
printf "GCP_USER=$GCP_USER\n"
if [[ "$2" = 'gcp' ]] || [[ "$2" = 'onprem' ]]; then
BLOCKCHAIN_HOSTING="$2"
else
printf "Invalid blockchain hosting argument: $2\n"
exit
fi
printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n"

OPTIONS="$2"
OPTIONS="$3"
printf "OPTIONS=$OPTIONS\n"

GCP_USER="runner"
printf "GCP_USER=$GCP_USER\n"

# Get confirmation.
printf "\n"
read -p "Do you want to proceed for $SEASON? [y/N]: " -n 1 -r
Expand Down Expand Up @@ -62,4 +77,4 @@ fi

# ssh into each instance, install packages and start up the server
printf "\n\n############################\n# Running monitoring #\n############################\n\n"
gcloud compute ssh $MONITORING_TARGET_ADDR --command "cd ./ain-blockchain; . setup_monitoring_gcp.sh $SEASON $GCP_USER && . start_monitoring_gcp.sh" --project $PROJECT_ID --zone $MONITORING_ZONE
gcloud compute ssh $MONITORING_TARGET_ADDR --command "cd ./ain-blockchain; . setup_monitoring_gcp.sh $SEASON $GCP_USER $BLOCKCHAIN_HOSTING && . start_monitoring_gcp.sh" --project $PROJECT_ID --zone $MONITORING_ZONE
File renamed without changes.
File renamed without changes.
21 changes: 16 additions & 5 deletions setup_monitoring_gcp.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#!/bin/bash

if [[ "$#" -lt 2 ]]; then
printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username>\n"
printf "Example: bash setup_monitoring_gcp.sh dev gcp_user\n"
function usage() {
printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username> [gcp|onprem]\n"
printf "Example: bash setup_monitoring_gcp.sh staging gcp_user gcp\n"
printf "Example: bash setup_monitoring_gcp.sh staging gcp_user onprem\n"
printf "\n"
exit
}

if [[ $# -lt 3 ]] || [[ $# -gt 3 ]]; then
usage
fi

printf "\n[[[[[ setup_monitoring_gcp.sh ]]]]]\n\n"

if [[ "$1" != 'dev' ]] && [[ "$1" != 'staging' ]] && [[ "$1" != 'sandbox' ]] && [[ "$1" != 'exp' ]] && [[ "$1" != 'spring' ]] && [[ "$1" != 'summer' ]] && [[ "$1" != 'mainnet' ]]; then
printf "Invalid <Season> argument: $1\n"
exit
fi
if [[ "$3" != 'gcp' ]] && [[ "$3" != 'onprem' ]]; then
printf "Invalid blockchain hosting argument: $3\n"
exit
fi

SEASON="$1"
GCP_USER="$2"

BLOCKCHAIN_HOSTING="$3"
printf "SEASON=$SEASON\n"
printf "GCP_USER=$GCP_USER\n"
printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n"
printf "\n"

printf 'Killing old jobs..\n'
Expand Down Expand Up @@ -47,6 +58,6 @@ mv prometheus*/ prometheus


printf 'Copying Prometheus yml file..\n'
PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}.yml"
PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}-${BLOCKCHAIN_HOSTING}.yml"
printf "PROMETHEUS_CONFIG_FILE=${PROMETHEUS_CONFIG_FILE}\n"
cp -f monitoring/${PROMETHEUS_CONFIG_FILE} prometheus/prometheus.yml

0 comments on commit 8e45715

Please sign in to comment.