Skip to content

Commit 5923b84

Browse files
committed
chore: 스크립트 수정3
1 parent 1c3d72e commit 5923b84

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,27 @@ jobs:
4747
script: |
4848
cd /home/ubuntu/app
4949
50-
echo "[deploy] kill old app if exists"
51-
pkill -f "java -jar" || true
52-
sleep 5
53-
54-
echo "[deploy] list jars"
55-
ls -al build/libs
56-
57-
JAR_PATH=$(ls -t build/libs/*.jar | head -n 1)
58-
echo "[deploy] Using JAR: $JAR_PATH"
59-
60-
if [ -z "$JAR_PATH" ]; then
61-
echo "[deploy] No JAR found under build/libs"
62-
exit 1
50+
echo "[deploy] stop old app"
51+
if [ -f app.pid ]; then
52+
PID=$(cat app.pid)
53+
if ps -p "$PID" > /dev/null 2>&1; then
54+
kill "$PID" || true
55+
sleep 5
56+
fi
57+
rm app.pid
6358
fi
64-
65-
echo "[deploy] start app with nohup in background"
59+
60+
echo "[deploy] start new app"
6661
DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
67-
nohup java -jar "$JAR_PATH" > app.log 2>&1 &
68-
62+
nohup java -jar build/libs/workingdead-0.0.1-SNAPSHOT.jar > app.log 2>&1 &
63+
64+
echo $! > app.pid
65+
6966
sleep 5
70-
71-
if pgrep -f "java -jar" > /dev/null; then
72-
echo "[deploy] Application is running."
73-
exit 0
67+
if ps -p "$(cat app.pid)" > /dev/null 2>&1; then
68+
echo "[deploy] Application started successfully"
7469
else
75-
echo "[deploy] Application failed to start."
70+
echo "[deploy] Application failed to start"
71+
tail -n 80 app.log || true
7672
exit 1
7773
fi

0 commit comments

Comments
 (0)