TeslaCN commented on code in PR #20038:
URL: https://github.com/apache/shardingsphere/pull/20038#discussion_r941938295


##########
shardingsphere-distribution/shardingsphere-proxy-distribution/src/main/resources/bin/start.sh:
##########
@@ -137,12 +156,57 @@ if [ -z "$PORT" ]; then
 fi
 
 CLASS_PATH=${CONF_PATH}:${CLASS_PATH}
-MAIN_CLASS=${MAIN_CLASS}" "${PORT}" "${CONF_PATH}" "${ADDRESSES}
+MAIN_CLASS="${MAIN_CLASS} ${PORT} ${CONF_PATH} ${ADDRESSES}"
+
+if [ $PORT = -1 ]; then
+  REAL_PORT=3307
+else
+  REAL_PORT=$PORT
+fi
 
-echo "Starting the $SERVER_NAME ..."
 echo "The classpath is ${CLASS_PATH}"
 echo "main class ${MAIN_CLASS}"
-
-nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH} 
${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
-sleep 1
-echo "Please check the STDOUT file: $STDOUT_FILE"
+echo "STDOUT log file: $STDOUT_FILE"
+echo -e "Starting the $SERVER_NAME ...\c"
+
+for((i=1;i<=10;i++)); do
+  if [ "$i" = "10" ]; then
+    echo "failed: Address already in use"
+    exit
+  fi
+
+  PORT_STATUS=$(netstat -ant |$GREP $REAL_PORT |$GREP LISTEN)
+  if [ -n "$PORT_STATUS" ]; then
+    echo -e ".\c"
+    sleep 1
+  else
+    break
+  fi
+done
+echo ""
+
+nohup $JAVA ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH} 
${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
+if [ $? -eq 0 ]; then
+  case "$OSTYPE" in
+  *solaris*)
+    pid=$(/bin/echo "${!}\\c")
+    ;;
+  *)
+    pid=$(/bin/echo -n $!)
+    ;;
+  esac
+  if [ $? -eq 0 ]; then
+    sleep 1
+    if ps -p "${pid}" > /dev/null 2>&1; then
+      echo "SUCCESS, PID: $pid"
+      exit 0
+    else
+      echo "FAILED TO START"
+    fi
+  else
+    echo "FAILED TO GET PID"
+  fi
+else
+  echo "SERVER DID NOT START"
+fi
+exit 1

Review Comment:
   Does it work in Docker?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to