From c28cd62914ac681b340489de053a3225c26cbd58 Mon Sep 17 00:00:00 2001 From: KiSeungMin Date: Wed, 17 Jul 2024 13:32:42 +0900 Subject: [PATCH] add deploy.sh --- appspec.yml | 5 +---- scripts/deploy.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 scripts/deploy.sh diff --git a/appspec.yml b/appspec.yml index 97c45c3..6ca3326 100644 --- a/appspec.yml +++ b/appspec.yml @@ -13,8 +13,5 @@ permissions: hooks: AfterInstall: - - location: scripts/stop.sh - timeout: 60 - ApplicationStart: - - location: scripts/start.sh + - location: scripts/deploy.sh timeout: 60 diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..74d4e26 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +REPOSITORY=/home/ubuntu/backend +cd $REPOSITORY + +APP_NAME=moduform +JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep 'backend-0.0.1-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