Skip to content

Commit

Permalink
fix : jar을 실행시키기 위한 deploy.sh 관련 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
손명진 authored and 손명진 committed Jul 29, 2024
1 parent 0a3c6d7 commit b780731
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
8 changes: 7 additions & 1 deletion appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/app/deploy
destination: /home/ubuntu/app/deploy

#배포가 끝나면 deploy.sh를 실행시킴 (우회하는 방법 사용)
hooks:
AfterInstall:
- location: execute-deploy.sh
timeout: 180
29 changes: 29 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

echo "> Checking pid of the running application..."

APP_BASE_PATH=/home/ubuntu/app/

CURRENT_PID=$(pgrep -f i-like-this-page)

echo "PID = $CURRENT_PID"

if [ -z $CURRENT_PID ]; then
echo "> There is no running application."
else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

echo "> Deploying a new application..."

echo "> Copy jar files"

cp $APP_BASE_PATH/deploy/build/libs/*.jar $APP_BASE_PATH/jar/

JAR_NAME=$(ls -tr $APP_BASE_PATH/jar/ | grep 'i-like-this-page' | tail -n 1)

echo "> JAR Name: $JAR_NAME"

nohup java -jar $APP_BASE_PATH/jar/$JAR_NAME &
5 changes: 5 additions & 0 deletions scripts/execute-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

touch /home/ubuntu/deploy.log

/home/ubuntu/deploy.sh > /home/ubuntu/deploy.log 2> /home/ubuntu/deploy.log < /dev/null &

0 comments on commit b780731

Please sign in to comment.