Skip to content

Commit

Permalink
[FEAT] #26 - Create script and yaml for aws codedeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlwo530 committed Aug 21, 2021
1 parent 3c53edd commit d3f9b0f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
20 changes: 20 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/jampick
permissions:
- object: /home/ubuntu/jampick
owner: ubuntu
group: ubuntu
mode: 755
hooks:
BeforeInstall:
- location: scripts/database.sh
timeout: 60
runas: root
AfterInstall:
- location: scripts/deploy.sh
timeout: 60
runas: root
17 changes: 17 additions & 0 deletions scripts/database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

if [ ! "$(docker ps -q -f name=my-mysql)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=my-mysql)" ]; then
echo "cleanup"
docker rm my-mysql
fi
echo "run your container"
docker run -d --name my-mysql my-docker-
docker run --name my-mysql \
-e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
-e MYSQL_DATABASE=jampick \
-v /home/ubuntu/mysql:/var/lib/mysql \
-d mysql:5.7 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
fi
22 changes: 22 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

REPOSITORY=/home/ubuntu/jampick
cd $REPOSITORY

APP_NAME=action_codedeploy
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.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 "> $JAR_PATH 배포"
nohup java -jar $JAR_PATH > /dev/null 2> /dev/null < /dev/null &

0 comments on commit d3f9b0f

Please sign in to comment.