@@ -11,7 +11,6 @@ echo "> νμ¬ κ΅¬λμ€μΈ Set νμΈ"
1111CURRENT_PROFILE=$( curl -s http://localhost/profile)
1212echo " > $CURRENT_PROFILE "
1313
14- # μ¬κ³ μλ set μ°ΎκΈ°: set1μ΄ μ¬μ©μ€μ΄λ©΄ set2κ° μ¬κ³ μκ³ , λ°λλ©΄ set1μ΄ μ¬κ³ μμ
1514if [ $CURRENT_PROFILE == set1 ]
1615then
1716 IDLE_PROFILE=set2
@@ -49,7 +48,6 @@ echo "> $IDLE_PROFILE λ°°ν¬"
4948nohup java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active=$IDLE_PROFILE $IDLE_APPLICATION_PATH >> /home/ubuntu/app/nohup.out 2>&1 &
5049
5150echo " > $IDLE_PROFILE 10μ΄ ν Health check μμ"
52- echo " > curl -s http://localhost:$IDLE_PORT /health "
5351sleep 10
5452
5553for retry_count in {1..10}
5856 up_count=$( echo $response | grep ' UP' | wc -l)
5957
6058 if [ $up_count -ge 1 ]
61- then # $up_count >= 1 ("UP" λ¬Έμμ΄μ΄ μλμ§ κ²μ¦)
59+ then
6260 echo " > Health check μ±κ³΅"
6361 break
6462 else
6563 echo " > Health checkμ μλ΅μ μ μ μκ±°λ νΉμ statusκ° UPμ΄ μλλλ€."
66- echo " > Health check: ${response} "
6764 fi
6865
6966 if [ $retry_count -eq 10 ]
7067 then
71- echo " > Health check μ€ν¨. "
72- echo " > Nginxμ μ°κ²°νμ§ μκ³ λ°°ν¬λ₯Ό μ’
λ£ν©λλ€."
68+ echo " > Health check μ€ν¨."
7369 exit 1
7470 fi
7571
76- echo " > Health check μ°κ²° μ€ν¨. μ¬μλ..."
7772 sleep 10
7873done
7974
80- echo " > Nginx μν νμΈ λ° λ³΅κ΅¬"
75+ echo " > Nginx 볡ꡬ"
8176sudo systemctl stop nginx 2> /dev/null || true
8277sleep 1
8378sudo systemctl start nginx
8479sleep 2
85- if sudo systemctl is-active --quiet nginx; then
86- echo " > Nginx μμ μ±κ³΅"
87- else
88- echo " > Nginx μμ μ€ν¨. κ°μ μ¬μμ μλ..."
89- sudo killall nginx 2> /dev/null || true
90- sleep 1
91- sudo nginx
92- sleep 2
93- fi
9480
95- echo " > λ°©νλ²½ κ·μΉ μ΄κΈ°ν (μΈλ°μ΄λ νΈλν½ νμ©)"
96- # UFW λΉνμ±ν
81+ echo " > λ°©νλ²½ μ΄κΈ°ν"
9782sudo ufw disable 2> /dev/null || true
98-
99- # iptables μ΄κΈ°ν - λͺ¨λ νΈλν½ νμ©
10083sudo iptables -P INPUT ACCEPT 2> /dev/null || true
10184sudo iptables -P FORWARD ACCEPT 2> /dev/null || true
10285sudo iptables -P OUTPUT ACCEPT 2> /dev/null || true
10386sudo iptables -F 2> /dev/null || true
104- sudo iptables -X 2> /dev/null || true
10587
10688echo " > μ€μμΉ"
10789sleep 10
10890/home/ubuntu/app/nonstop/switch.sh
10991
110- echo " > λ°°ν¬ μλ£. μ§λ¨ μ 보 μΆλ ₯ (logTail μΊ‘μ²μ©)..."
111- echo " =========================================="
112- echo " === [DIAG] Public IP ==="
113- curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/public-ipv4 2> /dev/null || echo " λ©νλ°μ΄ν° μ κ·Ό λΆκ°"
114- echo " "
115- echo " === [DIAG] Instance ID ==="
116- curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/instance-id 2> /dev/null || echo " λ©νλ°μ΄ν° μ κ·Ό λΆκ°"
117- echo " "
118- echo " === [DIAG] Security Groups ==="
119- curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/security-groups 2> /dev/null || echo " λ©νλ°μ΄ν° μ κ·Ό λΆκ°"
120- echo " "
121- echo " === [DIAG] Listening Ports ==="
122- sudo ss -tlnp 2> /dev/null | head -20
123- echo " "
124- echo " === [DIAG] Nginx Status ==="
125- sudo systemctl is-active nginx 2>&1
126- echo " "
127- echo " === [DIAG] Java Processes ==="
128- pgrep -a java 2> /dev/null | head -5
129- echo " "
130- echo " === [DIAG] iptables ==="
131- sudo iptables -L -n 2> /dev/null | head -20
132- echo " "
133- echo " === [DIAG] UFW Status ==="
134- sudo ufw status 2> /dev/null
135- echo " "
136- echo " === [DIAG] Network Interfaces ==="
137- ip addr show 2> /dev/null | grep -E " inet |state" | head -10
138- echo " "
139- echo " === [DIAG] Localhost Tests ==="
140- echo " 8081: $( curl -s -o /dev/null -w ' %{http_code}' http://localhost:8081/actuator/health 2> /dev/null) "
141- echo " 8082: $( curl -s -o /dev/null -w ' %{http_code}' http://localhost:8082/actuator/health 2> /dev/null) "
142- echo " 80: $( curl -s -o /dev/null -w ' %{http_code}' http://localhost/actuator/health 2> /dev/null) "
143- echo " profile: $( curl -s http://localhost/profile 2> /dev/null) "
144- echo " "
145- echo " === [DIAG] Memory ==="
146- free -h 2> /dev/null | head -3
147- echo " "
148- echo " === [DIAG] nohup.out (last 20 lines) ==="
149- tail -20 /home/ubuntu/app/nohup.out 2> /dev/null
150- echo " =========================================="
151- echo " > μ§λ¨ μΆλ ₯ μλ£. μλμ μ€ν¨ (logTail μΊ‘μ²)..."
92+ echo " ======= DIAG START ======="
93+ echo " [IP] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/public-ipv4 2> /dev/null || echo NONE) "
94+ echo " [INST] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/instance-id 2> /dev/null || echo NONE) "
95+ echo " [SG] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/security-groups 2> /dev/null || echo NONE) "
96+ echo " [MAC] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/mac 2> /dev/null || echo NONE) "
97+ MAC=$( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/mac 2> /dev/null)
98+ if [ -n " $MAC " ]; then
99+ echo " [VPC] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC /vpc-id 2> /dev/null || echo NONE) "
100+ echo " [SUBNET] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC /subnet-id 2> /dev/null || echo NONE) "
101+ echo " [SG-IDS] $( curl -s --connect-timeout 3 http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC /security-group-ids 2> /dev/null || echo NONE) "
102+ fi
103+ echo " [NGINX] $( sudo systemctl is-active nginx 2>&1 ) "
104+ echo " [PORTS] $( sudo ss -tlnp 2> /dev/null | grep -E ' :(80|8081|8082) ' || echo NONE) "
105+ echo " [JAVA] $( pgrep -a java 2> /dev/null | head -2 || echo NONE) "
106+ echo " [UFW] $( sudo ufw status 2> /dev/null | head -1) "
107+ echo " [IPT] $( sudo iptables -S 2> /dev/null | head -5) "
108+ echo " [LOCAL80] $( curl -s -o /dev/null -w ' %{http_code}' http://localhost/actuator/health 2> /dev/null) "
109+ echo " [LOCAL8081] $( curl -s -o /dev/null -w ' %{http_code}' http://localhost:8081/actuator/health 2> /dev/null) "
110+ echo " [LOCAL8082] $( curl -s -o /dev/null -w ' %{http_code}' http://localhost:8082/actuator/health 2> /dev/null) "
111+ echo " [PROFILE] $( curl -s http://localhost/profile 2> /dev/null) "
112+ echo " [MEM] $( free -m 2> /dev/null | grep Mem | awk ' {print $2"M total, "$3"M used, "$4"M free"}' ) "
113+ echo " ======= DIAG END ======="
152114exit 1
0 commit comments