-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: 새로운 AWS 계정에서 Dev 환경 CI/CD 구축 #416
- Loading branch information
Showing
5 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# 최대 반복 횟수 | ||
MAX_RETRIES=60 | ||
|
||
# 성공 상태 코드와 요청 URL | ||
SUCCESS_STATUS=200 | ||
HEALTH_CHECK_URL="localhost:8080/actuator/health" | ||
|
||
# 반복 시작 | ||
i=1 | ||
while [ "$i" -le "$MAX_RETRIES" ]; do | ||
# HTTP 요청 보내기 | ||
RESPONSE_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTH_CHECK_URL") | ||
echo "[TRY $i] StatusCode : $RESPONSE_STATUS " | ||
# 상태 코드 확인 | ||
if [ "$RESPONSE_STATUS" -eq "$SUCCESS_STATUS" ]; then | ||
echo "Success: Received $SUCCESS_STATUS status code on attempt $i." | ||
exit 0 | ||
fi | ||
|
||
# 1초 대기 | ||
sleep 1 | ||
|
||
# 반복 변수 증가 | ||
i=$((i + 1)) | ||
done | ||
|
||
# 실패 메시지 | ||
echo "Failure: Did not receive $SUCCESS_STATUS status code within $MAX_RETRIES attempts." | ||
sh kill-application.sh | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
PID=$(lsof -t -i:8080) | ||
|
||
# 프로세스 종료 | ||
if [ -z "$PID" ]; then | ||
echo "No process is using port 8080." | ||
else | ||
echo "Killing process with PID: $PID" | ||
kill -15 "$PID" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
PID=$(lsof -t -i:8080) | ||
|
||
# 프로세스 종료 | ||
if [ -z "$PID" ]; then | ||
echo "No process is using port 8080." | ||
else | ||
echo "Killing process with PID: $PID" | ||
kill -15 "$PID" | ||
|
||
# 직전 명령(프로세스 종료 명령)이 정상 동작했는지 확인 | ||
if [ $? -eq 0 ]; then | ||
echo "Process $PID terminated successfully." | ||
else | ||
echo "Failed to terminate process $PID." | ||
fi | ||
fi | ||
|
||
JAR_FILE=$(ls /home/ubuntu/app/*.jar | head -n 1) | ||
|
||
nohup java -Dspring.profiles.active=dev -Duser.timezone=Asia/Seoul -Dserver.port=8080 -jar "$JAR_FILE" & |