forked from nzpr/rnode-parallelism-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage-instance.sh
executable file
·36 lines (32 loc) · 1.35 KB
/
manage-instance.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
#!/bin/zsh
name=rnode-parallelism-test
export CLOUDSDK_COMPUTE_ZONE=us-east1-d
create_args=(
--machine-type=n1-standard-$3
--min-cpu-platform='Intel Skylake'
--image-project=ubuntu-os-cloud
--image-family=ubuntu-1910
--metadata-from-file=startup-script="startup-script.run"
--tags=collectd-out,http
--service-account=public-files-writer@developer-222401.iam.gserviceaccount.com
--scopes=https://www.googleapis.com/auth/cloud-platform
)
gcloud compute instances delete $name --quiet || true
gcloud compute instances create $name $create_args 2>&1 > ./.gcloud.log
IP=$(grep RUNNING .gcloud.log | awk '{print $5}')
echo "Installing instance... Visit http://$IP after several minutes to follow the progress. \
Do not close this shell, it will be closed automatically when benchmark is finished."
while ! curl -s $IP/perf_results_$1.txt | grep -q 'Finished'; do
sleep 1
done
mkdir -p results/$1
wget --quiet -P results/$1 $IP/perf_results_$1.txt
echo "Benchmark finished, results are in $IP/perf_results_$1.txt."
if $2; then
echo "Shutting down instance $name"
echo "Results saved into results/perf_results_$1.txt"
gcloud compute instances delete $name --quiet || true
exit
fi
echo "Tracing spans are available at http://$IP/jaeger"
echo "WARNING!!! Instance is still running and have to be payed for. Run gcloud compute instances delete $name asap."