-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codeDeploy 배포시 jar가 정상적으로 종료되지않아 프로세스 정상 종료 확인 로직
- Loading branch information
Showing
1 changed file
with
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
PROJECT_ROOT="/home/ec2-user/mapddang-back" | ||
JAR_FILE="$PROJECT_ROOT/dnd-travel.jar" | ||
|
||
DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
|
||
TIME_NOW=$(date +%c) | ||
|
||
# 현재 구동 중인 애플리케이션 pid 확인 | ||
CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
CURRENT_PID=$(ps -ef | grep java | grep "$JAR_FILE" | grep -v grep | awk '{print $2}') | ||
|
||
# 프로세스가 켜져 있으면 종료 | ||
if [ -z $CURRENT_PID ]; then | ||
echo "$TIME_NOW > 현재 실행 중인 애플리케이션이 없음" >> $DEPLOY_LOG | ||
else | ||
echo "$TIME_NOW > 실행 중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG | ||
kill -15 $CURRENT_PID | ||
fi | ||
|
||
# 프로세스 종료 확인 | ||
sleep 5 | ||
if ps -p $CURRENT_PID > /dev/null; then | ||
echo "$TIME_NOW > 애플리케이션 강제 종료 시도" >> $DEPLOY_LOG | ||
kill -9 $CURRENT_PID | ||
fi | ||
fi |