Skip to content

Commit

Permalink
Merge pull request #51 from dongkyun0713/dongkyun
Browse files Browse the repository at this point in the history
ํŒŒ์ผ ๊ตฌ์กฐ ๋ณ€๊ฒฝ
  • Loading branch information
dongkyun0713 authored Feb 12, 2024
2 parents 706dd22 + 13f050c commit ec37298
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
Binary file modified Titto_Backend/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions Titto_Backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ out/

### VS Code ###
.vscode/
.DS_Store
23 changes: 23 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/app
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/stop.sh
timeout: 60
runas: ubuntu
ApplicationStart:
- location: scripts/start.sh
timeout: 60
runas: ubuntu
Binary file added scripts/.DS_Store
Binary file not shown.
22 changes: 22 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

PROJECT_ROOT="/home/ubuntu/app"
JAR_FILE="/home/ubuntu/Titto_Backend-0.0.1-SNAPSHOT.jar"

APP_LOG="$PROJECT_ROOT/application.log"
ERROR_LOG="$PROJECT_ROOT/error.log"
DEPLOY_LOG="$PROJECT_ROOT/deploy.log"

TIME_NOW=$(date +%c)

# build ํŒŒ์ผ ๋ณต์‚ฌ
echo "$TIME_NOW > $JAR_FILE ํŒŒ์ผ ๋ณต์‚ฌ" >> $DEPLOY_LOG
cp $PROJECT_ROOT/Titto_Backend/build/libs/*.jar /home/ubuntu

# jar ํŒŒ์ผ ์‹คํ–‰
echo "$TIME_NOW > $JAR_FILE ํŒŒ์ผ ์‹คํ–‰" >> $DEPLOY_LOG
cd /home/ubuntu
nohup java -jar $JAR_FILE > /dev/null 2> /dev/null < /dev/null &

CURRENT_PID=$(pgrep -f $JAR_FILE)
echo "$TIME_NOW > ์‹คํ–‰๋œ ํ”„๋กœ์„ธ์Šค ์•„์ด๋”” $CURRENT_PID ์ž…๋‹ˆ๋‹ค." >> $DEPLOY_LOG
19 changes: 19 additions & 0 deletions scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

PROJECT_ROOT="/home/ubuntu/app"
JAR_FILE="/home/ubuntu/Titto_Backend-0.0.1-SNAPSHOT.jar"

DEPLOY_LOG="$PROJECT_ROOT/deploy.log"

TIME_NOW=$(date +%c)

# ํ˜„์žฌ ๊ตฌ๋™ ์ค‘์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ pid ํ™•์ธ
CURRENT_PID=$(pgrep -f $JAR_FILE)

# ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ผœ์ ธ ์žˆ์œผ๋ฉด ์ข…๋ฃŒ
if [ -z $CURRENT_PID ]; then
echo "$TIME_NOW > ํ˜„์žฌ ์‹คํ–‰์ค‘์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์—†์Šต๋‹ˆ๋‹ค" >> $DEPLOY_LOG
else
echo "$TIME_NOW > ์‹คํ–‰์ค‘์ธ $CURRENT_PID ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ข…๋ฃŒ " >> $DEPLOY_LOG
kill -15 $CURRENT_PID
fi

0 comments on commit ec37298

Please sign in to comment.