-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch_instances.sh
More file actions
executable file
·73 lines (63 loc) · 1.89 KB
/
launch_instances.sh
File metadata and controls
executable file
·73 lines (63 loc) · 1.89 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
INSTANCE_TAG="testing round 2"
COMMAND='echo "Success" > /home/ubuntu/testing.log'
# AMI="ami-660ae31e"
INSTANCE_TYPE="c4.xlarge"
AMI="ami-85f378fd" #extract
# INSTANCE_TYPE="c3.2xlarge"
INSTANCE_COUNT=7
KEY_NAME="taskonomy"
SECURITY_GROUP="launch-wizard-1"
SPOT_PRICE=0.2
ZONE="us-west-2"
START_AT=1
EXIT_AFTER=1
# Now generate transfers
# TASKS="autoencoder colorization denoise edge2d edge3d impainting keypoint2d keypoint3d reshade rgb2depth rgb2mist rgb2sfnorm"
# IGNORED: colorization rgb2mist
TASKS="autoencoder denoise edge2d edge3d impainting keypoint2d keypoint3d reshade rgb2depth rgb2sfnorm"
KEPT_TASKS=$TASKS
# "denoise"
COUNTER=0
for src in $KEPT_TASKS; do
for dst in $KEPT_TASKS; do
COUNTER=$[$COUNTER +1]
if [ "$COUNTER" -lt "$START_AT" ]; then
echo "Skipping at $COUNTER (starting at $START_AT)"
continue
fi
echo "running $COUNTER"
USER_DATA=$(echo """
export INSTANCE_TAG=\"API Server (v7)\";
cd /home/ubuntu/taskonomy-web-api;
git pull origin master;
source activate analysis;
bash register_ec2_server.sh;
bash start_server.sh;
python generate_nginx_config.py > test.txt && mv test.txt /etc/nginx/sites-available/default;
service nginx restart
# systemctl restart nginx;
""" | base64 | tr -d '\n' )
echo "$USER_DATA" | base64 -D
aws ec2 request-spot-instances \
--spot-price $SPOT_PRICE \
--instance-count $INSTANCE_COUNT \
--region $ZONE \
--launch-specification \
"{ \
\"ImageId\":\"$AMI\", \
\"InstanceType\":\"$INSTANCE_TYPE\", \
\"KeyName\":\"$KEY_NAME\", \
\"SecurityGroups\": [\"$SECURITY_GROUP\"], \
\"UserData\":\"$USER_DATA\" \
}"
if [ "$COUNTER" -ge "$EXIT_AFTER" ]; then
echo "EXITING before $COUNTER (after $EXIT_AFTER)"
break
fi
# echo USER_DATA
done
if [ "$COUNTER" -ge "$EXIT_AFTER" ]; then
echo "EXITING after $COUNTER"
break
fi
done