From 7e2f2bbe6b597d03d717b00567bdf8370961abab Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Tue, 19 Mar 2024 00:06:48 +0800 Subject: [PATCH 1/6] add DB_ADDRESS env var --- .gitignore | 13 +++++++------ deployment/auto-deploy-eventmesh-dashboard.sh | 2 +- .../src/main/resources/application-dev.yml | 2 +- .../src/test/resources/application-test.yml | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 1098c796..bd99c747 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - ### STS ### .apt_generated .classpath @@ -78,6 +72,13 @@ dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties +### Gradle ### +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + ### Log Files ### *.log logs/ diff --git a/deployment/auto-deploy-eventmesh-dashboard.sh b/deployment/auto-deploy-eventmesh-dashboard.sh index 01aae6c5..56704b43 100644 --- a/deployment/auto-deploy-eventmesh-dashboard.sh +++ b/deployment/auto-deploy-eventmesh-dashboard.sh @@ -59,7 +59,7 @@ if [ $LOCAL != $REMOTE ]; then mvn clean package # Start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-.log file - nohup java -jar $JAR_FILE_PATH > $APP_LOG 2>&1 & + nohup java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar $JAR_FILE_PATH > $APP_LOG 2>&1 & echo $! > $PID_LOG # Log the event diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 3b3c83b3..73f471b0 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -30,7 +30,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + url: jdbc:mysql://${DB_ADDRESS:localhost:3306}/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: ${DB_USERNAME:root} password: ${DB_PASSWORD:password} diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml index ee44e7c2..89dbea25 100644 --- a/eventmesh-dashboard-console/src/test/resources/application-test.yml +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -21,7 +21,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/eventmesh_dashboard_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + url: jdbc:mysql://${DB_ADDRESS:localhost:3306}/eventmesh_dashboard_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: ${DB_USERNAME:root} password: ${DB_PASSWORD:password} From d8633efc48aa64ea0cfec95ba2cb5a89d1a1c3a2 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Tue, 19 Mar 2024 00:08:09 +0800 Subject: [PATCH 2/6] add env file --- .gitignore | 5 ++++- deployment/.env | 22 +++++++++++++++++++ deployment/auto-deploy-eventmesh-dashboard.sh | 6 ++++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 deployment/.env diff --git a/.gitignore b/.gitignore index bd99c747..7f22e5ac 100644 --- a/.gitignore +++ b/.gitignore @@ -83,4 +83,7 @@ build/ *.log logs/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* \ No newline at end of file +hs_err_pid* + +### Devops ### +.env \ No newline at end of file diff --git a/deployment/.env b/deployment/.env new file mode 100644 index 00000000..fb4175df --- /dev/null +++ b/deployment/.env @@ -0,0 +1,22 @@ +# +# 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. + +# Credentials +DB_ADDRESS=localhost:3306 +DB_USERNAME=root +DB_PASSWORD=password \ No newline at end of file diff --git a/deployment/auto-deploy-eventmesh-dashboard.sh b/deployment/auto-deploy-eventmesh-dashboard.sh index 56704b43..d9623916 100644 --- a/deployment/auto-deploy-eventmesh-dashboard.sh +++ b/deployment/auto-deploy-eventmesh-dashboard.sh @@ -32,6 +32,10 @@ APP_LOG=~/service/eventmesh-dashboard/deployment/eventmesh-dashboard-$(date +"%Y # Jar file path JAR_FILE_PATH=~/service/eventmesh-dashboard/eventmesh-dashboard-console/target/eventmesh-dashboard-console-0.0.1-SNAPSHOT.jar +# Load environment variables from external file +ENV_FILE=~/service/eventmesh-dashboard/deployment/.env +source $ENV_FILE + # Update the git repository cd $REPO_PATH git fetch origin dev @@ -78,7 +82,7 @@ else mvn clean package # Start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-.log file - nohup java -jar $JAR_FILE_PATH > $APP_LOG 2>&1 & + nohup java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar $JAR_FILE_PATH > $APP_LOG 2>&1 & echo $! > $PID_LOG # Log the event From c77203f1f85270b150d48ef83543955290324ce8 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Tue, 19 Mar 2024 00:22:55 +0800 Subject: [PATCH 3/6] skip tests & add manual --- deployment/README.md | 26 +++++++++++++++++++ deployment/auto-deploy-eventmesh-dashboard.sh | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 deployment/README.md diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 00000000..e14bbd70 --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,26 @@ +## Auto Deploy EventMesh Dashboard + +### Usage + +``` +cd ~/service +git clone -b dev https://github.com/apache/eventmesh-dashboard.git +cd eventmesh-dashboard +chmod +x deployment/auto-deploy-eventmesh-dashboard.sh +``` + +Edit credentials: + +``` +vim deployment/.env +``` + +Add task to crontab: + +``` +crontab -e +``` + +``` +0 * * * * ~/service/eventmesh-dashboard/deployment/auto-deploy-eventmesh-dashboard.sh +``` \ No newline at end of file diff --git a/deployment/auto-deploy-eventmesh-dashboard.sh b/deployment/auto-deploy-eventmesh-dashboard.sh index d9623916..24ca44be 100644 --- a/deployment/auto-deploy-eventmesh-dashboard.sh +++ b/deployment/auto-deploy-eventmesh-dashboard.sh @@ -60,7 +60,7 @@ if [ $LOCAL != $REMOTE ]; then fi # Compile and package the Jar file - mvn clean package + mvn clean package -DskipTests # Start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-.log file nohup java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar $JAR_FILE_PATH > $APP_LOG 2>&1 & @@ -79,7 +79,7 @@ else 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 + mvn clean package -DskipTests # Start the springboot application and record the process id to pid.log file, redirect console logs to eventmesh-dashboard-.log file nohup java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar $JAR_FILE_PATH > $APP_LOG 2>&1 & From 254e19d62e7c47526b87009cc150c79a18753bc9 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Tue, 19 Mar 2024 00:38:26 +0800 Subject: [PATCH 4/6] add a hello endpoint --- .../dashboard/console/controller/MetricsController.java | 6 ++++++ .../console/controller/SubscriptionController.java | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java index 689f833c..bedbbdd5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java @@ -17,6 +17,8 @@ package org.apache.eventmesh.dashboard.console.controller; +import org.apache.eventmesh.dashboard.common.dto.Result; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -30,4 +32,8 @@ public Object druidStat() { return DruidStatManagerFacade.getInstance().getDataSourceStatDataList(); } + @GetMapping("/hello") + public Result hello() { + return Result.success("Hello, EventMesh Dashboard!"); + } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java index 1af09aee..6d53a963 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java @@ -69,5 +69,4 @@ public Result> listSubscriptions( @RequestParam(name = "group", defaultValue = "") String group) { return Result.success(subscriptionCore.retrieveConfigs(page, size, dataId, group)); } - } From 6e183bf69c90dfcadf9e94955318a8317e096715 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Tue, 19 Mar 2024 15:57:24 +0800 Subject: [PATCH 5/6] exclude .env --- deployment/{.env => .env.example} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename deployment/{.env => .env.example} (89%) diff --git a/deployment/.env b/deployment/.env.example similarity index 89% rename from deployment/.env rename to deployment/.env.example index fb4175df..5e2799d0 100644 --- a/deployment/.env +++ b/deployment/.env.example @@ -16,7 +16,10 @@ # specific language governing permissions and limitations # under the License. -# Credentials +# Copy this .env.example file to the .env file +# and edit your credentials. + +# Database credentials DB_ADDRESS=localhost:3306 DB_USERNAME=root DB_PASSWORD=password \ No newline at end of file From 1de19dedb7983c4995e4e897ac067a7597f33c3d Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Tue, 19 Mar 2024 16:01:00 +0800 Subject: [PATCH 6/6] refine manual --- deployment/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/README.md b/deployment/README.md index e14bbd70..f1bd7471 100644 --- a/deployment/README.md +++ b/deployment/README.md @@ -12,6 +12,7 @@ chmod +x deployment/auto-deploy-eventmesh-dashboard.sh Edit credentials: ``` +cp deployment/.env.example deployment/.env vim deployment/.env ```