Skip to content

Commit

Permalink
refine the script
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed Mar 15, 2024
1 parent 14af6eb commit bf2e71d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions deployment/auto-deploy-eventmesh-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
REPO_PATH=~/service/eventmesh-dashboard

# SpringBoot process ID file path
PID_LOG=./eventmesh-dashboard-pid.log
PID_LOG=~/service/eventmesh-dashboard/deployment/eventmesh-dashboard-pid.log

# Automatic deployment log file path
AUTO_DEPLOY_LOG=./auto-deploy-eventmesh-dashboard.log
# Automatic deployment shell script log file path
AUTO_DEPLOY_LOG=~/service/eventmesh-dashboard/deployment/auto-deploy-eventmesh-dashboard.log

# EventMesh Dashboard log file path
APP_LOG=~/service/eventmesh-dashboard/deployment/eventmesh-dashboard-$(date +"%Y-%m-%d-%H-%M-%S").log

# Jar file path
JAR_FILE_PATH=~/service/eventmesh-dashboard/eventmesh-dashboard-console/target/eventmesh-dashboard-console-0.0.1-SNAPSHOT.jar

# Check if the pid.log file exists, if not, create an empty file
touch $PID_LOG

# Update the git repository
cd $REPO_PATH
git fetch origin dev
Expand All @@ -46,7 +46,7 @@ if [ $LOCAL != $REMOTE ]; then
echo "$(date +"%Y-%m-%d %H:%M:%S") - change detected." >> $AUTO_DEPLOY_LOG

# Terminate the old process
if [ -f $PID_LOG ]; then
if [ -s $PID_LOG ]; then
PID=$(cat $PID_LOG)
if [ -n "$PID" ]; then
kill $PID
Expand All @@ -55,11 +55,11 @@ if [ $LOCAL != $REMOTE ]; then
fi
fi

# Compile and package the Jar file using Maven
# Compile and package the Jar file
mvn clean package

# Start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-<current time>.log file
nohup java -jar $JAR_FILE_PATH > eventmesh-dashboard-$(date +"%Y-%m-%d-%H-%M-%S").log 2>&1 &
nohup java -jar $JAR_FILE_PATH > $APP_LOG 2>&1 &
echo $! > $PID_LOG

# Log the event
Expand All @@ -70,14 +70,17 @@ else
# Log the event
echo "$(date +"%Y-%m-%d %H:%M:%S") - no change detected." >> $AUTO_DEPLOY_LOG

if [ -f $PID_LOG ]; then
if [ -s $PID_LOG ]; then
# If the pid.log file exists, no action is performed
echo "$(date +"%Y-%m-%d %H:%M:%S") - application running, no operation performed." >> $AUTO_DEPLOY_LOG
else
# If the pid.log file does not exist, start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-<current time>.log file
nohup java -jar $JAR_FILE_PATH > eventmesh-dashboard-$(date +"%Y-%m-%d-%H-%M-%S").log 2>&1 &
# If the pid.log file does not exist, compile and package the Jar file
mvn clean package

# Start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-<current time>.log file
nohup java -jar $JAR_FILE_PATH > $APP_LOG 2>&1 &
echo $! > $PID_LOG

# Log the event
echo "$(date +"%Y-%m-%d %H:%M:%S") - no pid.log file, start application." >> $AUTO_DEPLOY_LOG
fi
Expand Down

0 comments on commit bf2e71d

Please sign in to comment.