forked from brentley/ecsdemo-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.sh
executable file
·37 lines (31 loc) · 700 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
#!/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=1a
color=Crimson
;;
101)
zone=1b
color=CornflowerBlue
;;
102)
zone=1c
color=LightGreen
;;
*)
zone=unknown
color=Yellow
;;
esac
# Am I on ec2 instances?
if [[ ${zone} == "unknown" ]]; then
zone=$(curl -m2 -s http:https://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.availabilityZone' | cut -f3 -d-)
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