From 86d2d3d5f066142bf995f779ef212704c9afe9ad Mon Sep 17 00:00:00 2001 From: JongKyeong Kim Date: Sun, 7 Jan 2024 22:10:33 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appspec.yml | 15 +++++++++++++++ scritps/deploy.sh | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/appspec.yml b/appspec.yml index e69de29b..7b113ddb 100644 --- a/appspec.yml +++ b/appspec.yml @@ -0,0 +1,15 @@ +version: 0.0 +os: linux + +files: + - source: / + destination: /home/ubuntu/GLOG +permissions: + - object: /home/ubuntu/GLOG/ + owner: ubuntu + group: ubuntu +hooks: + AfterInstall: + - location: scripts/deploy.sh + timeout: 60 + runas: ubuntu \ No newline at end of file diff --git a/scritps/deploy.sh b/scritps/deploy.sh index e69de29b..7713234c 100644 --- a/scritps/deploy.sh +++ b/scritps/deploy.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +REPOSITORY=/home/ubuntu/GLOG +cd $REPOSITORY + +APP_NAME=moduform +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 "> 종료할 애플리케이션이 없습니다." +else + echo "> kill -9 $CURRENT_PID" + kill -15 $CURRENT_PID + sleep 5 +fi + +echo "> Deploy - $JAR_PATH " +nohup java -jar $JAR_PATH > /dev/null 2> /dev/null < /dev/null & \ No newline at end of file