Skip to content

Commit

Permalink
FEAT : add scripts for deploy and appspec file
Browse files Browse the repository at this point in the history
  • Loading branch information
yummygyudon committed Nov 24, 2023
1 parent 2923d43 commit 0ea1507
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
Empty file removed .github/workflows/SKT_T1_CD.yaml
Empty file.
Empty file removed .github/workflows/SKT_T1_CI.yaml
Empty file.
15 changes: 15 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/app
hooks:
ApplicationStop:
- location: script/stop.sh
timeout: 60
runas: root
AfterInstall:
- location: script/start.sh
timeout: 60
runas: root
25 changes: 25 additions & 0 deletions script/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 인스턴스에 클론 받은 디렉토리 이름을 `app`으로 바꿔야합니다.
APPLICATION_PATH=/home/ubuntu/app
# shellcheck disable=SC2164
cd $APPLICATION_PATH

# shellcheck disable=SC2010
JAR_NAME=$(ls $APPLICATION_PATH/build/libs/ | grep '.jar' | tail -n 1)

# shellcheck disable=SC2034
JAR_PATH=build/libs/$JAR_NAME
JAR_PID=$(pgrep -f $JAR_NAME)

if [ -z $JAR_PID ]
then
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다."
else
echo "> sudo kill -15 $JAR_PID"
sudo kill -15 $JAR_PID
sleep 10
fi

echo "> $JAR_PATH 배포" #3
# shellcheck disable=SC2153
# shellcheck disable=SC2024
sudo nohup java -jar -Dspring.profiles.active=prod "$JAR_PATH" >nohup.out 2>&1 </dev/null &
5 changes: 5 additions & 0 deletions script/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# shellcheck disable=SC2046
# shellcheck disable=SC2009
kill $(ps aux | grep java | grep -v grep | awk '{print $2}')
echo "java stopped"

0 comments on commit 0ea1507

Please sign in to comment.