forked from brentley/ecsdemo-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.sh
executable file
·42 lines (35 loc) · 826 Bytes
/
startup.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
#!/bin/sh
set -x
IP=$(ip route show |grep -o src.* |cut -f2 -d" ")
NETWORK=$(echo ${IP} | cut -f3 -d.)
case "${NETWORK}" in
100)
zone=a
color=Crimson
;;
101)
zone=b
color=CornflowerBlue
;;
102)
zone=c
color=LightGreen
;;
*)
zone=unknown
color=Yellow
;;
esac
# kubernetes sets routes differently -- so we will discover our IP differently
if [[ ${IP} == "" ]]; then
IP=$(hostname -i)
fi
# Am I on ec2 instances?
if [[ ${zone} == "unknown" ]]; then
zone=$(curl -m2 -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.availabilityZone' | grep -o .$)
fi
export CODE_HASH="$(cat code_hash.txt)"
export AZ="${IP} in AZ-${zone}"
# exec bundle exec thin start
RAILS_ENV=production rake assets:precompile
exec rails s -e production -b 0.0.0.0