Skip to content

Commit

Permalink
NABI-254--chore : CICD script, deploy.sh 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
BeommoKoo-dev committed Nov 17, 2023
1 parent 3dcd58e commit 6768b95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
env:
PROJECT_NAME: nabi
BUCKET_NAME: team-01-bucket
CODE_DEPLOY_APP_NAME: nabi-market
DEPLOYMENT_GROUP_NAME: nabi-instance-group
CODE_DEPLOY_APP_NAME: team01-codedeploy
DEPLOYMENT_GROUP_NAME: team01-instance-group

permissions:
contents: read
Expand Down
26 changes: 12 additions & 14 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#!/bin/bash
BUILD_JAR=$(ls $REPOSITORY/build/libs/*.jar)
JAR_NAME=$(basename $BUILD_JAR)
echo "> build 파일명: $JAR_NAME" >> /home/ubuntu/action/deploy.log
#!/usr/bin/env bash

echo "> build 파일 복사" >> /home/ubuntu/action/deploy.log
DEPLOY_PATH=/home/ubuntu/action/
cp $BUILD_JAR $DEPLOY_PATH
REPOSITORY=/home/ubuntu/nabi
cd $REPOSITORY

echo "> 현재 실행중인 애플리케이션 pid 확인" >> /home/ubuntu/action/deploy.log
CURRENT_PID=$(pgrep -f $JAR_NAME)
APP_NAME=nabi
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep 'SNAPSHOT.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME

CURRENT_PID=$(pgrep -f $APP_NAME)

if [ -z $CURRENT_PID ]
then
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> /home/ubuntu/action/deploy.log
echo "> 종료할 애플리케이션이 없습니다."
else
echo "> kill -15 $CURRENT_PID"
echo "> kill -9 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME
echo "> DEPLOY_JAR 배포" >> /home/ubuntu/today/deploy.log
nohup java -jar $DEPLOY_JAR >> /home/ubuntu/today/deploy.log 2>/home/ubuntu/action/deploy_err.log &
echo "> Deploy - $JAR_PATH "
nohup java -jar $JAR_PATH > /dev/null 2> /dev/null < /dev/null &

0 comments on commit 6768b95

Please sign in to comment.