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

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


The following commit(s) were added to refs/heads/dev by this push:
     new 3747ce228 [Feature] Only Shell to control pid file creation and 
deletion (#2639)
3747ce228 is described below

commit 3747ce2288f3dc6f9da45c7c73ad0bc2b37aebc8
Author: gongzhongqiang <[email protected]>
AuthorDate: Sun Apr 16 17:12:43 2023 +0800

    [Feature] Only Shell to control pid file creation and deletion (#2639)
    
    Co-authored-by: gongzhongqiang <[email protected]>
---
 .../src/main/assembly/bin/streampark.sh            | 35 ++++++----------------
 .../console/StreamParkConsoleBootstrap.java        | 10 +------
 2 files changed, 10 insertions(+), 35 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 eaee6db62..e05e44824 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
@@ -367,35 +367,18 @@ start() {
     -Dlogging.config="\"${APP_CONF}\"/logback-spring.xml" \
     -Dspring.config.location="\"${PROPER}\"" \
     -Djava.io.tmpdir="\"$APP_TMPDIR\"" \
-    -Dpid="\"${APP_PID}\"" \
     org.apache.streampark.console.StreamParkConsoleBootstrap >> "$APP_OUT" 
2>&1 "&"
 
+    mypid=$!
 
-   if [ $? -eq "0" ]; then
-      local SLEEP_INTERVAL=5
-      local STARTED=0
-      while [ $SLEEP_INTERVAL -ge 0 ]; do
-         # shellcheck disable=SC2236
-         if [ -f "$APP_PID" ]; then
-           if [ -s "$APP_PID" ]; then
-             # shellcheck disable=SC2006
-             echo_g "StreamPark start successful. pid: `cat "$APP_PID"`"
-             STARTED=1
-             break
-           fi
-         fi
-         if [ $SLEEP_INTERVAL -gt 0 ]; then
-           sleep 1
-         fi
-         # shellcheck disable=SC2006
-         SLEEP_INTERVAL=`expr $SLEEP_INTERVAL - 1 `
-      done
-      if [ $STARTED -eq 0 ] ;then
-        echo_g "StreamPark start successful."
-      fi
-   else
-      echo_r "StreamPark start failed."
-   fi
+    # Add to pid file if successful start
+    if [[ ${mypid} =~ ${IS_NUMBER} ]] && kill -0 $mypid > /dev/null 2>&1 ; then
+        echo $mypid >> "$APP_PID"
+        echo_g "StreamPark start successful. pid: `cat "$APP_PID"`"
+    else
+        echo_r "StreamPark start failed."
+        exit 1
+    fi
 }
 
 debug() {
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/StreamParkConsoleBootstrap.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/StreamParkConsoleBootstrap.java
index 86fa0b2ff..a9e3bf316 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/StreamParkConsoleBootstrap.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/StreamParkConsoleBootstrap.java
@@ -17,12 +17,9 @@
 
 package org.apache.streampark.console;
 
-import org.apache.streampark.common.util.SystemPropertyUtils;
-
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.context.ApplicationPidFileWriter;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 /**
@@ -50,11 +47,6 @@ import 
org.springframework.scheduling.annotation.EnableScheduling;
 public class StreamParkConsoleBootstrap {
 
   public static void main(String[] args) {
-    SpringApplication application = new 
SpringApplication(StreamParkConsoleBootstrap.class);
-    String pid = SystemPropertyUtils.get("pid");
-    if (pid != null) {
-      application.addListeners(new ApplicationPidFileWriter(pid));
-    }
-    application.run();
+    SpringApplication.run(StreamParkConsoleBootstrap.class, args);
   }
 }

Reply via email to