-
Notifications
You must be signed in to change notification settings - Fork 5
/
launch-clients.sh
executable file
·50 lines (33 loc) · 1.04 KB
/
launch-clients.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
env=$1
ec2_count=$2
if [ "$#" -ne 2 ]; then
echo "Usage: launch-clients.sh [env] [ec2-count]"
exit 1
fi
cd $(dirname "$0")
source scripts/launcher/functions.sh
load_conf client $env
echo -e "Launching game client on \033[92m$INSTANCE_TYPE\033[0m instances in \033[92m$REGION\033[0m region ..."
echo -e "Total \033[92m$ec2_count\033[0m instances, with \033[92m$EC2_LAUNCH_INTERVAL\033[0m seconds interval."
for i in `seq 1 $ec2_count`;
do
# give some green color see-see
echo -e "\033[92mLaunching instance No.$i ...\033[0m"
instance_id=$(run_instance client)
echo "Instance $instance_id launched."
echo "Tagging the instance ..."
tag_instance client $env $instance_id
echo "Instance tagged successfully."
# wait for next launch
if [ "$i" -ne "$ec2_count" ]; then
for i in `seq 1 $EC2_LAUNCH_INTERVAL`;
do
sleep 1
echo -ne "Waiting for next launch: \033[91m`expr $EC2_LAUNCH_INTERVAL - $i`\033[0m\r"
done
echo -ne "\r"
fi
done
echo -e "\033[92mAll Instances launched successfully.\033[0m"