Skip to content

Commit 8e45715

Browse files
authored
Merge pull request #1327 from ainblockchain/feature/platfowner/feature
Update blockchain monitoring deploy scripts for onprem hosting
2 parents 6e6ffdb + eb13600 commit 8e45715

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

deploy_monitoring_gcp.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#!/bin/bash
22

3-
if [[ "$#" -lt 1 ]]; then
4-
printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [--setup]\n"
5-
printf "Example: bash deploy_monitoring_gcp.sh dev --setup\n"
6-
printf "Example: bash deploy_monitoring_gcp.sh dev\n"
3+
function usage() {
4+
printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem} [--setup]\n"
5+
printf "Example: bash deploy_monitoring_gcp.sh staging gcp \n"
6+
printf "Example: bash deploy_monitoring_gcp.sh staging gcp --setup\n"
7+
printf "Example: bash deploy_monitoring_gcp.sh staging onprem \n"
8+
printf "Example: bash deploy_monitoring_gcp.sh staging onprem --setup\n"
79
printf "\n"
810
exit
11+
}
12+
13+
if [[ $# -lt 2 ]] || [[ $# -gt 3 ]]; then
14+
usage
915
fi
16+
1017
printf "\n[[[[[ deploy_monitoring_gcp.sh ]]]]]\n\n"
1118

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

28-
GCP_USER="runner"
29-
printf "GCP_USER=$GCP_USER\n"
35+
if [[ "$2" = 'gcp' ]] || [[ "$2" = 'onprem' ]]; then
36+
BLOCKCHAIN_HOSTING="$2"
37+
else
38+
printf "Invalid blockchain hosting argument: $2\n"
39+
exit
40+
fi
41+
printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n"
3042

31-
OPTIONS="$2"
43+
OPTIONS="$3"
3244
printf "OPTIONS=$OPTIONS\n"
3345

46+
GCP_USER="runner"
47+
printf "GCP_USER=$GCP_USER\n"
48+
3449
# Get confirmation.
3550
printf "\n"
3651
read -p "Do you want to proceed for $SEASON? [y/N]: " -n 1 -r
@@ -62,4 +77,4 @@ fi
6277

6378
# ssh into each instance, install packages and start up the server
6479
printf "\n\n############################\n# Running monitoring #\n############################\n\n"
65-
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
80+
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.

setup_monitoring_gcp.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
#!/bin/bash
22

3-
if [[ "$#" -lt 2 ]]; then
4-
printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username>\n"
5-
printf "Example: bash setup_monitoring_gcp.sh dev gcp_user\n"
3+
function usage() {
4+
printf "Usage: bash setup_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username> [gcp|onprem]\n"
5+
printf "Example: bash setup_monitoring_gcp.sh staging gcp_user gcp\n"
6+
printf "Example: bash setup_monitoring_gcp.sh staging gcp_user onprem\n"
67
printf "\n"
78
exit
9+
}
10+
11+
if [[ $# -lt 3 ]] || [[ $# -gt 3 ]]; then
12+
usage
813
fi
14+
915
printf "\n[[[[[ setup_monitoring_gcp.sh ]]]]]\n\n"
1016

1117
if [[ "$1" != 'dev' ]] && [[ "$1" != 'staging' ]] && [[ "$1" != 'sandbox' ]] && [[ "$1" != 'exp' ]] && [[ "$1" != 'spring' ]] && [[ "$1" != 'summer' ]] && [[ "$1" != 'mainnet' ]]; then
1218
printf "Invalid <Season> argument: $1\n"
1319
exit
1420
fi
21+
if [[ "$3" != 'gcp' ]] && [[ "$3" != 'onprem' ]]; then
22+
printf "Invalid blockchain hosting argument: $3\n"
23+
exit
24+
fi
1525

1626
SEASON="$1"
1727
GCP_USER="$2"
18-
28+
BLOCKCHAIN_HOSTING="$3"
1929
printf "SEASON=$SEASON\n"
2030
printf "GCP_USER=$GCP_USER\n"
31+
printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n"
2132
printf "\n"
2233

2334
printf 'Killing old jobs..\n'
@@ -47,6 +58,6 @@ mv prometheus*/ prometheus
4758

4859

4960
printf 'Copying Prometheus yml file..\n'
50-
PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}.yml"
61+
PROMETHEUS_CONFIG_FILE="prometheus-${SEASON}-${BLOCKCHAIN_HOSTING}.yml"
5162
printf "PROMETHEUS_CONFIG_FILE=${PROMETHEUS_CONFIG_FILE}\n"
5263
cp -f monitoring/${PROMETHEUS_CONFIG_FILE} prometheus/prometheus.yml

0 commit comments

Comments
 (0)