From 3ea18c49e9fb18392bed8926b7ba8c0b27196f5b Mon Sep 17 00:00:00 2001 From: leeesoraaa Date: Sun, 28 Jul 2024 04:09:58 +0900 Subject: [PATCH] test3 commit --- appspec.yml | 18 ++++++++++++++++++ scripts/deploy.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 appspec.yml create mode 100644 scripts/deploy.sh diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..392b0e1 --- /dev/null +++ b/appspec.yml @@ -0,0 +1,18 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /home/ubuntu/app/ + overwrite: yes + +permissions: + - object: / + pattern: "**" + owner: ubuntu + group: ubuntu + +hooks: + ApplicationStart: + - location: deploy.sh + timeout: 60 + runas: ubuntu \ No newline at end of file diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..0488659 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,29 @@ +REPOSITORY=/home/ubuntu/app + +echo "> 현재 구동 중인 애플리케이션 pid 확인" + +CURRENT_PID=$(pgrep -fla java | grep hayan | awk '{print $1}') + +echo "현재 구동 중인 애플리케이션 pid: $CURRENT_PID" + +if [ -z "$CURRENT_PID" ]; then + echo "현재 구동 중인 애플리케이션이 없으므로 종료하지 않습니다." +else + echo "> kill -15 $CURRENT_PID" + kill -15 $CURRENT_PID + sleep 5 +fi + +echo "> 새 애플리케이션 배포" + +JAR_NAME=$(ls -tr $REPOSITORY/*SNAPSHOT.jar | tail -n 1) + +echo "> JAR NAME: $JAR_NAME" + +echo "> $JAR_NAME 에 실행권한 추가" + +chmod +x $JAR_NAME + +echo "> $JAR_NAME 실행" + +nohup java -jar -Duser.timezone=Asia/Seoul $JAR_NAME >> $REPOSITORY/nohup.out 2>&1 & \ No newline at end of file