Skip to content

Commit

Permalink
feat: codeDeploy 설정 파일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Juhongseok committed Oct 17, 2023
1 parent 77fdfce commit c251f29
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/code

permissions:
- object: /

hooks:
AfterInstall:
- location: scripts/deploy.sh
timeout: 60
28 changes: 28 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

PROJECT_NAME=resumeme
REPOSITORY=/home/ubuntu/code
PACKAGE=$REPOSITORY/build/libs/
JAR_NAME=$(ls -tr $PACKAGE | grep 'SNAPSHOT.jar' | tail -n 1)
JAR_PATH=$PACKAGE$JAR_NAME

echo $JAR_NAME
echo $JAR_PATH

cd $REPOSITORY

CURRENT_PID=$(pgrep -f $PROJECT_NAME)

if [ -z $CURRENT_PID ]
then
echo "> 종료할 애플리케이션이 없습니다"
else
echo "> 실행 중인 애플리케이션 종료 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

echo "> 배포 - $JAR_PATH"
chmod +x $JAR_PATH

sudo nohup java -jar $JAR_PATH --spring.profiles.active=prod > /home/ubuntu/log/nohup_log.out 2> /home/ec2-user/log/nohup_error.out &

0 comments on commit c251f29

Please sign in to comment.