You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/06/18 12:27:56 UTC

[incubator-linkis] branch dev-1.2.0 updated: [Improvement-2293] fix.The new lsof will monitor whether the port is occupied when executing checkenv and install. (#2300)

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

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


The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
     new 210c9329c [Improvement-2293] fix.The new lsof will monitor whether the port is occupied when executing checkenv and install. (#2300)
210c9329c is described below

commit 210c9329c36f38c19186ba587ede8971c9642704
Author: ruY <43...@users.noreply.github.com>
AuthorDate: Sat Jun 18 20:27:50 2022 +0800

    [Improvement-2293] fix.The new lsof will monitor whether the port is occupied when executing checkenv and install. (#2300)
---
 assembly-combined-package/bin/checkEnv.sh | 46 +++++++++++++++++++++++++++++++
 web/install.sh                            | 14 ++++++++++
 2 files changed, 60 insertions(+)

diff --git a/assembly-combined-package/bin/checkEnv.sh b/assembly-combined-package/bin/checkEnv.sh
index 17f667b00..04302bece 100644
--- a/assembly-combined-package/bin/checkEnv.sh
+++ b/assembly-combined-package/bin/checkEnv.sh
@@ -17,6 +17,7 @@
 shellDir=`dirname $0`
 workDir=`cd ${shellDir}/..;pwd`
 source ${workDir}/bin/common.sh
+source ${workDir}/deploy-config/linkis-env.sh
 
 say() {
     printf 'check command fail \n %s\n' "$1"
@@ -72,6 +73,14 @@ function checkSpark(){
  isSuccess "execute cmd: spark-submit --version "
 }
 
+portIsOccupy=false
+function check_service_port() {
+    pid=`lsof -i :$SERVER_PORT | grep -v "PID"`
+    if [ "$pid" != "" ];then
+      echo "$SERVER_PORT already used"
+      portIsOccupy=true
+    fi
+}
 
 check_cmd() {
     command -v "$1" > /dev/null 2>&1
@@ -97,10 +106,47 @@ echo "check tar"
 need_cmd tar
 echo "check sed"
 need_cmd sed
+echo "check lsof"
+need_cmd lsof
 echo "<-----end to check used cmd---->"
 
 checkPythonAndJava
 
+SERVER_PORT=$EUREKA_PORT
+check_service_port
+
+SERVER_PORT=$GATEWAY_PORT
+check_service_port
+
+SERVER_PORT=$MANAGER_PORT
+check_service_port
+
+SERVER_PORT=$ENGINECONNMANAGER_PORT
+check_service_port
+
+SERVER_PORT=$ENGINECONN_PLUGIN_SERVER_PORT
+check_service_port
+
+SERVER_PORT=$ENTRANCE_PORT
+check_service_port
+
+SERVER_PORT=$PUBLICSERVICE_PORT
+check_service_port
+
+SERVER_PORT=$CS_PORT
+check_service_port
+
+SERVER_PORT=$DATASOURCE_MANAGER_PORT
+check_service_port
+
+SERVER_PORT=$METADATA_MANAGER_PORT
+check_service_port
+
+if [ "$portIsOccupy" = true ];then
+  echo "The port is already in use, please check before installing"
+  exit 1
+fi
+
 if [ "$ENABLE_SPARK" == "true" ]; then
   checkSpark
 fi
diff --git a/web/install.sh b/web/install.sh
index 22e7f0535..9b5c5b643 100644
--- a/web/install.sh
+++ b/web/install.sh
@@ -67,6 +67,14 @@ echo "local ip:${linkis_ipaddr}"
 echo "================================== print config info end =================================="
 echo ""
 
+portIsOccupy=false
+checkPort(){
+    pid=`lsof -nP -iTCP:$linkis_port -sTCP:LISTEN`
+    if [ "$pid" != "" ];then
+      echo "$linkis_port already used"
+      portIsOccupy=true
+    fi
+}
 
 #create nginx conf file
 linkisConf(){
@@ -195,6 +203,12 @@ centos6(){
 
 }
 
+checkPort
+if [ "$portIsOccupy" = true ];then
+  echo "The port is already in use, please check before installing"
+  exit 1
+fi
+
 # centos 6
 if [[ $version -eq 6 ]]; then
     centos6


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org