You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2024/06/01 05:26:08 UTC

(incubator-streampark) branch alert created (now 5e69c69e0)

This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a change to branch alert
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


      at 5e69c69e0 [Bug] Dingtalk alert bug fixed

This branch includes the following new commits:

     new 5e69c69e0 [Bug] Dingtalk alert bug fixed

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-streampark) 01/01: [Bug] Dingtalk alert bug fixed

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch alert
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git

commit 5e69c69e0f6a6099320fcf93fb76f162fdc6e99f
Author: benjobs <be...@gmail.com>
AuthorDate: Sat Jun 1 13:25:55 2024 +0800

    [Bug] Dingtalk alert bug fixed
---
 .../src/main/assembly/bin/streampark.sh                   |  8 ++++----
 .../streampark/console/base/util/BashJavaUtils.java       | 15 +++++++++++++--
 .../alert/impl/DingTalkAlertNotifyServiceImpl.java        | 14 +++++---------
 .../service/alert/impl/LarkAlertNotifyServiceImpl.java    |  1 +
 .../streampark-console-webapp/vite.config.ts              |  2 +-
 5 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh b/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
index f28ff76b3..81af07693 100755
--- a/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
+++ b/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh
@@ -313,15 +313,15 @@ get_pid() {
   fi
 
   # shellcheck disable=SC2006
-  local serverPort=`$_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --yaml "server.port" "$CONFIG"`
+  local serverPort=`$_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --get_yaml "server.port" "$CONFIG"`
   if [[ x"${serverPort}" == x"" ]]; then
     echo_r "server.port is required, please check $CONFIG"
     exit 1;
   else
      # shellcheck disable=SC2006
       # shellcheck disable=SC2155
-      local used=`lsof -i:"$serverPort" | wc -l`
-      if [[ "$used" -gt 0 ]]; then
+      local used=`$_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --check_port "$serverPort"`
+      if [[ x"${used}" == x"used" ]]; then
         # shellcheck disable=SC2006
         local PID=`jps -l | grep "$APP_MAIN" | awk '{print $1}'`
         if [[ ! -z $PID ]]; then
@@ -359,7 +359,7 @@ start() {
   fi
 
    # shellcheck disable=SC2006
-   local workspace=`$_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --yaml "streampark.workspace.local" "$CONFIG"`
+   local workspace=`$_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --get_yaml "streampark.workspace.local" "$CONFIG"`
    if [[ ! -d $workspace ]]; then
      echo_r "ERROR: streampark.workspace.local: \"$workspace\" is invalid path, Please reconfigure in $CONFIG"
      echo_r "NOTE: \"streampark.workspace.local\" Do not set under APP_HOME($APP_HOME). Set it to a secure directory outside of APP_HOME.  "
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/BashJavaUtils.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/BashJavaUtils.java
index ec6120cae..faf8b8ead 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/BashJavaUtils.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/BashJavaUtils.java
@@ -19,23 +19,34 @@ package org.apache.streampark.console.base.util;
 
 import org.apache.streampark.common.util.PropertiesUtils;
 
+import java.io.IOException;
+import java.net.ServerSocket;
 import java.util.Arrays;
 import java.util.Map;
 
 public class BashJavaUtils {
 
-  public static void main(String[] args) {
+  public static void main(String[] args) throws IOException {
     String action = args[0].toLowerCase();
     String[] actionArgs = Arrays.copyOfRange(args, 1, args.length);
 
     switch (action) {
-      case "--yaml":
+      case "--get_yaml":
         String key = actionArgs[0];
         String conf = actionArgs[1];
         Map<String, String> confMap = PropertiesUtils.fromYamlFileAsJava(conf);
         String value = confMap.get(key);
         System.out.println(value);
         break;
+      case "--check_port":
+        Integer port = Integer.parseInt(actionArgs[0]);
+        try {
+          new ServerSocket(port);
+          System.out.println("free");
+        } catch (Exception e) {
+          System.out.println("used");
+        }
+        break;
       default:
         break;
     }
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/DingTalkAlertNotifyServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/DingTalkAlertNotifyServiceImpl.java
index e7c0452e1..0a456b59e 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/DingTalkAlertNotifyServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/DingTalkAlertNotifyServiceImpl.java
@@ -146,23 +146,19 @@ public class DingTalkAlertNotifyServiceImpl implements AlertNotifyService {
    * @return the webhook
    */
   private String getWebhook(AlertDingTalkParams params) {
-    String urlPef = "https://oapi.dingtalk.com/robot/send";
+    String urlPrefix = "https://oapi.dingtalk.com/robot/send";
     if (StringUtils.hasLength(params.getAlertDingURL())) {
-      urlPef = params.getAlertDingURL();
+      urlPrefix = params.getAlertDingURL().replaceFirst("\\?.*", "");
     }
-    if (!urlPef.endsWith("access_token=")) {
-      urlPef += "?access_token=";
-    }
-
     String url;
     if (params.getSecretEnable()) {
       Long timestamp = System.currentTimeMillis();
       url =
           String.format(
-              "%s%s&timestamp=%d&sign=%s",
-              urlPef, params.getToken(), timestamp, getSign(params.getSecretToken(), timestamp));
+              "%s?access_token=%s&timestamp=%d&sign=%s",
+              urlPrefix, params.getToken(), timestamp, getSign(params.getSecretToken(), timestamp));
     } else {
-      url = String.format("%s%s", urlPef, params.getToken());
+      url = String.format("%s?access_token=%s", urlPrefix, params.getToken());
     }
     if (log.isDebugEnabled()) {
       log.debug("The alarm robot url of DingTalk contains signature is {}", url);
diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/LarkAlertNotifyServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/LarkAlertNotifyServiceImpl.java
index 971c23b6d..c6d6e1bd9 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/LarkAlertNotifyServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/alert/impl/LarkAlertNotifyServiceImpl.java
@@ -135,6 +135,7 @@ public class LarkAlertNotifyServiceImpl implements AlertNotifyService {
    * @return the webhook
    */
   private String getWebhook(AlertLarkParams params) {
+    larkProxyUrl = larkProxyUrl.replaceFirst("/open-apis/bot/v2/hook/(.*)", "");
     String url = String.format(larkProxyUrl + "/open-apis/bot/v2/hook/%s", params.getToken());
     if (log.isDebugEnabled()) {
       log.debug("The alarm robot url of Lark is {}", url);
diff --git a/streampark-console/streampark-console-webapp/vite.config.ts b/streampark-console/streampark-console-webapp/vite.config.ts
index edb6b6a4c..441ccf089 100644
--- a/streampark-console/streampark-console-webapp/vite.config.ts
+++ b/streampark-console/streampark-console-webapp/vite.config.ts
@@ -80,7 +80,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
       pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
     },
     build: {
-      target: 'es2015',
+      target: 'es2018',
       cssTarget: 'chrome80',
       outDir: OUTPUT_DIR,
       // minify: 'terser',