gradle ํ๋ก์ ํธ ๋ฐฐํฌ ์คํฌ๋ฆฝํธ ๋ง๋ค๊ธฐ
git clone
git clone https://github.com/ALOHA-CLASS/HelloSpringBoot.git
Bash
๋ณต์ฌ
build.gradle
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'com.joeun'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
bootWar {
archiveFileName = 'hello-application.war'
}
Bash
๋ณต์ฌ
start.sh
#!/bin/bash
# ๋ณ์ ์ ์ธ (=) ์๋ค๋ก ๊ณต๋ฐฑโ
PROJECT_NAME=hello-application
WORKSPACE=/home/joeun/workspace
REPOSITORY=/home/joeun/workspace/HelloSpringBoot
DEPLOY_PATH=/home/joeun/workspace/HelloSpringBoot/build/libs
# ํ๋ก์ ํธ ๊ฒฝ๋ก๋ก ์ด๋
echo "> ${REPOSITORY} ๋ก ์ด๋"
cd $REPOSITORY
# GIT PULL ์งํ
echo "> GIT PULL"
if git pull; then
echo "> git pull ์ฑ๊ณต"
else
echo "> git pull ์คํจ"
exit 1
fi
# ๋น๋ ์์
echo "> gradle clean build"
./gradlew clean build
# ํ์ฌ ์คํ ์ค์ธ ์๋ฒ pid(ํ๋ก์ธ์ค ์์ด๋) ํ์ธ
CURRENT_PID=$(pgrep -f "${PROJECT_NAME}.war")
echo "> ํ์ฌ ์คํ ์ค์ธ ์๋ฒ pid : ${CURRENT_PID}"
# ์คํ ์ค์ธ ์๋ฒ ์๋์ง ํ์ธ
if [ -z "$CURRENT_PID" ]; then
echo "> ํ์ฌ ์คํ ์ค์ธ ์๋ฒ ์์"
else
echo "> ํ์ฌ ์คํ ์ค์ธ ์๋ฒ ์ข
๋ฃ"
kill -15 $CURRENT_PID
sleep 5
fi
# ์ ํ๋ฆฌ์ผ์ด์
์ฌ๋ฐฐํฌ
echo "> ์๋ก์ด ์ ํ๋ฆฌ์ผ์ด์
๋ฐฐํฌ"
cd $DEPLOY_PATH
nohup java -jar "${PROJECT_NAME}.war" &
Bash
๋ณต์ฌ