Skip to content

Commit

Permalink
[ISSUE apache#64] Support automated deployment and Fix runtime packag…
Browse files Browse the repository at this point in the history
…ing errors (apache#65)

* add back missing build label

* Fix module name

* add test scope

* exclude log4j-to-slf4j

* exclude log4j-slf4j-impl

* add auto deploy script

* add license

* refine the script
  • Loading branch information
Pil0tXia committed Mar 15, 2024
1 parent 058ba06 commit 7c7981d
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 1 deletion.
87 changes: 87 additions & 0 deletions deployment/auto-deploy-eventmesh-dashboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
#
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Git repository path
REPO_PATH=~/service/eventmesh-dashboard

# SpringBoot process ID file path
PID_LOG=~/service/eventmesh-dashboard/deployment/eventmesh-dashboard-pid.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

# Update the git repository
cd $REPO_PATH
git fetch origin dev
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse origin/dev)

if [ $LOCAL != $REMOTE ]; then
# If the remote dev branch is newer than the local one, update the local dev branch code
git pull origin dev

# Log the event
echo "$(date +"%Y-%m-%d %H:%M:%S") - change detected." >> $AUTO_DEPLOY_LOG

# Terminate the old process
if [ -s $PID_LOG ]; then
PID=$(cat $PID_LOG)
if [ -n "$PID" ]; then
kill $PID
# Log the event
echo "$(date +"%Y-%m-%d %H:%M:%S") - kill running application." >> $AUTO_DEPLOY_LOG
fi
fi

# 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") - start new application." >> $AUTO_DEPLOY_LOG
else
# If there are no new changes in the remote dev branch

# Log the event
echo "$(date +"%Y-%m-%d %H:%M:%S") - no change detected." >> $AUTO_DEPLOY_LOG

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, 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
fi
31 changes: 31 additions & 0 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
<!-- <groupId>junit</groupId>-->
<!-- <artifactId>junit-dep</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- storage redis client -->
Expand Down Expand Up @@ -125,6 +129,33 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion eventmesh-dashboard-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<groupId>org.apache.eventmesh.dashboard.service</groupId>
<artifactId>eventmesh-dashboard-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eventmesh-dashboard-core</name>
<name>eventmesh-dashboard-service</name>

<properties>
<java.version>1.8</java.version>
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,18 @@
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>${mybatis-spring-boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down

0 comments on commit 7c7981d

Please sign in to comment.