Skip to content

Commit ea23436

Browse files
committed
APP_ENV set correctly. UserpoolId set correctly
1 parent a39f82a commit ea23436

3 files changed

Lines changed: 73 additions & 75 deletions

File tree

deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ r53_domain_name="${rgurl//http[s]*:\/\//}"
493493
jqcmd='.HostedZones[] | select(.Name=='"\"${r53_domain_name}.\""')|.Id'
494494
hosted_zone=$(aws route53 list-hosted-zones-by-name --dns-name "$r53_domain_name" | jq -r "$jqcmd" | sed -e 's#\/hostedzone\/##')
495495
echo "Creating configs locally"
496-
./makeconfigs.sh "$userpoolclient_id" "$userpool_id" "$bucketname" "$appuser" "$appuserpassword" \
496+
export RG_ENV="$env"
497+
./makeconfigs.sh "$userpool_id" "$userpoolclient_id" "$bucketname" "$appuser" "$appuserpassword" \
497498
"$runid" "$rgurl" "$region" "ROLE_NAME" "$ac_name" "$hosted_zone"
498499
echo "Uploading configs to $bucketname"
499500
aws s3 cp "$localhome"/config.tar.gz s3://"$bucketname"

scripts/fixconfigs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
version="0.1.11"
2+
version="0.1.12"
33
echo "Fixing configs...(fixconfig.sh v$version)"
44

55
[ -z "$RG_HOME" ] && RG_HOME='/opt/deploy/sp2'
@@ -56,7 +56,7 @@ echo "Copying docker-compose.yml from $RG_SRC to $RG_HOME"
5656
# trunk-ignore(shellcheck/SC2016)
5757
repcmd='s#\${PWD}#'$RG_HOME'#'
5858
echo "Modifying docker-compose.yml"
59-
sed -e "$repcmd" "$RG_SRC/docker-compose.yml" >"$RG_HOME/docker-compose.yml"
59+
sed -e "$repcmd" "$RG_SRC/docker-compose.yml" -e "s#APP_ENV=.*#APP_ENV=$RG_ENV#" >"$RG_HOME/docker-compose.yml"
6060
echo "Modified docker-compose.yml with APP_ENV=$RG_ENV"
6161

6262
echo 'Configuration changed successfully'

scripts/start_server.sh

Lines changed: 69 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
2-
version="0.1.8"
2+
version="0.1.9"
33
echo "Starting server....(start_server.sh v$version)"
44
if [ "$1" == "-h" ]; then
5-
echo "Usage: `basename $0` application_url"
6-
echo ' Param 1: (optional) URL for SNS Callback'
7-
echo ' Will use public-host-name if not passed'
8-
echo ' e.g. https://myrg.example.com'
9-
echo ' Param 2: (optional) Target Group ARN to register with'
10-
exit 0
5+
echo "Usage: $(basename $0) <application_url> <target_group_arn>"
6+
echo ' Param 1: (optional) URL for SNS Callback'
7+
echo ' Will use public-host-name if not passed'
8+
echo ' e.g. https://myrg.example.com'
9+
echo ' Param 2: (optional) Target Group ARN to register with'
10+
exit 0
1111
fi
1212

13-
[ -z $RG_HOME ] && RG_HOME='/opt/deploy/sp2'
13+
[ -z "$RG_HOME" ] && RG_HOME='/opt/deploy/sp2'
1414
echo "RG_HOME=$RG_HOME"
1515

1616
myurl=$1
@@ -27,24 +27,23 @@ docker pull $(cat "$RG_HOME/docker-compose.yml" | grep -i image | grep -i nginx
2727
echo 'Pulling docker image for notificationsink'
2828
docker pull $(cat "$RG_HOME/docker-compose.yml" | grep -i image | grep -i notificationsink | awk '{print $2}' | uniq | tr -d '\r')
2929

30-
3130
echo 'Modifying HttpResponseHopLimit'
3231
ec2instanceid=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
3332
aws ec2 modify-instance-metadata-options --instance-id "$ec2instanceid" --http-put-response-hop-limit 2 --http-endpoint enabled
3433

3534
if [ -z $myurl ]; then
36-
public_host_name="$(wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname)"
37-
baseurl="$public_host_name"
35+
public_host_name="$(wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname)"
36+
baseurl="$public_host_name"
3837
else
39-
baseurl="$myurl"
38+
baseurl="$myurl"
4039
fi
4140
echo "BaseURL=$baseurl"
4241
echo "TGARN=$tgarn"
4342

4443
if [ ! -z $tgarn ]; then
45-
ec2instanceid=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
46-
echo "Registering instance $ec2instanceid with Target group: $tgarn"
47-
aws elbv2 register-targets --targets "Id=$ec2instanceid,Port=$port" --target-group-arn "$tgarn"
44+
ec2instanceid=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
45+
echo "Registering instance $ec2instanceid with Target group: $tgarn"
46+
aws elbv2 register-targets --targets "Id=$ec2instanceid,Port=$port" --target-group-arn "$tgarn"
4847
fi
4948
echo "Calling swarm init will respond with error if this node is already part of a swarm"
5049
docker swarm init
@@ -60,68 +59,66 @@ sleep 5
6059

6160
#Check if stack is deployed
6261
echo "Checking if stack is deployed"
63-
service_count=`docker service ls -q | wc -l`
64-
if [ "${service_count}" -gt 0 ]; then
65-
echo "Service count deployed is $service_count"
62+
service_count=$(docker service ls -q | wc -l)
63+
if [ "${service_count}" -gt 0 ]; then
64+
echo "Service count deployed is $service_count"
6665
else
67-
echo "Service not deployed successfully"
68-
exit 1
66+
echo "Service not deployed successfully"
67+
exit 1
6968
fi
7069

7170
sleep 30
7271

73-
function check_stack_status(){
74-
#Check if all the services are up
75-
state_replicated=0
76-
for i in `docker service ls -q`; do
77-
echo "$i"
78-
replicated=`docker service inspect --pretty $i | grep -i "Service Mode" | awk '{print $3}'`
79-
echo "Replicated service status: $replicated"
80-
if [ "${replicated}" == "Replicated" ]; then
81-
replicas=`docker service inspect --pretty $i | grep -i replicas | awk '{print $2}'`
82-
echo "Replicas count : $replicas"
83-
running_replicas=`docker service ps $i |grep -i running | wc -l`
84-
echo "Running replicas count : $running_replicas"
85-
if [ ${replicas} -ne "${running_replicas}" ]; then
86-
let "state_replicated=state_replicated+1"
87-
fi
88-
fi
89-
done
90-
echo "Stack replication : $state_replicated"
91-
if [ "${state_replicated}" -gt 0 ]; then
92-
echo "CRITICAL - Not all services are replicated"
93-
else
94-
echo "OK - All services are replicated"
95-
fi
96-
return $state_replicated
72+
function check_stack_status() {
73+
#Check if all the services are up
74+
state_replicated=0
75+
for i in $(docker service ls -q); do
76+
echo "$i"
77+
replicated=$(docker service inspect --pretty $i | grep -i "Service Mode" | awk '{print $3}')
78+
echo "Replicated service status: $replicated"
79+
if [ "${replicated}" == "Replicated" ]; then
80+
replicas=$(docker service inspect --pretty $i | grep -i replicas | awk '{print $2}')
81+
echo "Replicas count : $replicas"
82+
running_replicas=$(docker service ps $i | grep -i running | wc -l)
83+
echo "Running replicas count : $running_replicas"
84+
if [ ${replicas} -ne "${running_replicas}" ]; then
85+
let "state_replicated=state_replicated+1"
86+
fi
87+
fi
88+
done
89+
echo "Stack replication : $state_replicated"
90+
if [ "${state_replicated}" -gt 0 ]; then
91+
echo "CRITICAL - Not all services are replicated"
92+
else
93+
echo "OK - All services are replicated"
94+
fi
95+
return $state_replicated
9796
}
9897

99-
for i in {0..3}
100-
do
101-
echo "Checking stack status $i"
102-
check_stack_status
103-
res=$?
104-
echo "$res"
105-
if [ "${res}" == 0 ]; then
106-
echo "All services are up"
107-
break
108-
else
109-
sleep 30
110-
fi
111-
done
112-
98+
for i in {0..3}; do
99+
echo "Checking stack status $i"
100+
check_stack_status
101+
res=$?
102+
echo "$res"
103+
if [ "${res}" == 0 ]; then
104+
echo "All services are up"
105+
break
106+
else
107+
sleep 30
108+
fi
109+
done
110+
113111
#Check if web application is up and running
114-
for i in {0..3}
115-
do
116-
sleep 10
117-
echo "Checking if web application is up and running"
118-
status_code=$(curl -sL -w "%{http_code}\n" "$baseurl" -o /dev/null)
119-
if [ "$status_code" -ne 200 ]; then
120-
echo "Application is not up, responded with status $status_code"
121-
else
122-
echo "Application is up and running, status code response is $status_code"
123-
break
124-
fi
125-
done
126-
127-
echo "Done"
112+
for i in {0..3}; do
113+
sleep 10
114+
echo "Checking if web application is up and running"
115+
status_code=$(curl -sL -w "%{http_code}\n" "$baseurl" -o /dev/null)
116+
if [ "$status_code" -ne 200 ]; then
117+
echo "Application is not up, responded with status $status_code"
118+
else
119+
echo "Application is up and running, status code response is $status_code"
120+
break
121+
fi
122+
done
123+
124+
echo "Done"

0 commit comments

Comments
 (0)