-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
45 lines (38 loc) Β· 1012 Bytes
/
Copy pathdeploy.sh
File metadata and controls
45 lines (38 loc) Β· 1012 Bytes
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
#!/bin/bash
set -e
APP_DIR=/home/ec2-user/app
JAR_PATH=$(ls $APP_DIR/*.jar | grep -v plain | head -1)
echo "> JAR νμΌ: $JAR_PATH"
echo "> μ€ν μ€μΈ μ ν리μΌμ΄μ
μ’
λ£"
CURRENT_PID=$(pgrep -f '\.jar' || true)
if [ -n "$CURRENT_PID" ]; then
echo "> μ’
λ£: $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
else
echo "> μ€ν μ€μΈ μ ν리μΌμ΄μ
μμ"
fi
echo "> μ ν리μΌμ΄μ
μμ"
nohup java -jar \
-Duser.timezone=Asia/Seoul \
$JAR_PATH \
>> /home/ec2-user/app/nohup.out 2>&1 &
echo "> 15μ΄ ν ν¬μ€μ²΄ν¬ μμ"
sleep 15
for i in {1..10}; do
RESPONSE=$(curl -s http://localhost:8080/actuator/health || true)
if echo "$RESPONSE" | grep -q '"status":"UP"'; then
echo "> ν¬μ€μ²΄ν¬ μ±κ³΅"
break
fi
echo "> ν¬μ€μ²΄ν¬ μ€ν¨($i/10): $RESPONSE"
if [ $i -eq 10 ]; then
echo "> λ°°ν¬ μ€ν¨"
exit 1
fi
sleep 10
done
echo "> Nginx μμ"
sudo systemctl start nginx || true
sudo systemctl enable nginx || true
echo "> λ°°ν¬ μλ£"