-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from software-project-yu/develop
👷ci:script변경
- Loading branch information
Showing
4 changed files
with
40 additions
and
37 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 |
---|---|---|
@@ -1,29 +1,21 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
# Set the path where your JAR files are located | ||
ROOT_PATH="/home/ubuntu/libs" # Adjust to the correct directory | ||
JAR="$ROOT_PATH/application.jar" | ||
PROJECT_ROOT="/home/ubuntu/app" | ||
JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
|
||
APP_LOG="$ROOT_PATH/application.log" | ||
ERROR_LOG="$ROOT_PATH/error.log" | ||
START_LOG="$ROOT_PATH/start.log" | ||
APP_LOG="$PROJECT_ROOT/application.log" | ||
ERROR_LOG="$PROJECT_ROOT/error.log" | ||
DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
|
||
NOW=$(date +%c) | ||
TIME_NOW=$(date +%c) | ||
|
||
# Log the JAR copy action | ||
echo "[$NOW] $JAR 복사" >> $START_LOG | ||
# build 파일 복사 | ||
echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG | ||
cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE | ||
|
||
# Adjusted copy path to the build directory, assuming your JAR is in /libs/ | ||
cp $ROOT_PATH/spring-github-action-1.0.0.jar $JAR | ||
# jar 파일 실행 | ||
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG | ||
nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & | ||
|
||
# Log the JAR execution | ||
echo "[$NOW] > $JAR 실행" >> $START_LOG | ||
|
||
# Run the application in the background | ||
nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG & | ||
|
||
# Get the service PID | ||
SERVICE_PID=$(pgrep -f $JAR) | ||
|
||
# Log the service PID | ||
echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG | ||
CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
echo "$TIME_NOW > 실행된 프로세스 아이디 $CURRENT_PID 입니다." >> $DEPLOY_LOG |
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,14 +1,19 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
ROOT_PATH="/home/ubuntu/libs" # JAR 파일이 위치한 디렉토리 | ||
JAR="$ROOT_PATH/demo-0.0.1-SNAPSHOT.jar" # 해당 디렉토리 내 JAR 파일 | ||
STOP_LOG="$ROOT_PATH/stop.log" | ||
SERVICE_PID=$(pgrep -f $JAR) # 실행중인 Spring 서버의 PID | ||
PROJECT_ROOT="/home/ubuntu/app" | ||
JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
|
||
if [ -z "$SERVICE_PID" ]; then | ||
echo "서비스 NouFound" >> $STOP_LOG | ||
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 "서비스 종료 " >> $STOP_LOG | ||
kill "$SERVICE_PID" | ||
# kill -9 $SERVICE_PID # 강제 종료를 하고 싶다면 이 명령어 사용 | ||
fi | ||
echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG | ||
kill -15 $CURRENT_PID | ||
fi |