shaofengshi closed pull request #353: KYLIN-3697 Check port availability when 
starts kylin instance
URL: https://github.com/apache/kylin/pull/353
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/build/bin/check-env.sh b/build/bin/check-env.sh
index cd745d4526..5b14e0af7d 100755
--- a/build/bin/check-env.sh
+++ b/build/bin/check-env.sh
@@ -80,4 +80,7 @@ then
     then
         quit "Failed to create $SPARK_HISTORYLOG_DIR. Please make sure the 
user has right to access $SPARK_HISTORYLOG_DIR"
     fi
-fi
\ No newline at end of file
+fi
+
+${KYLIN_HOME}/bin/check-port-availability.sh ||  exit 1;
+
diff --git a/build/bin/check-port-availability.sh 
b/build/bin/check-port-availability.sh
new file mode 100644
index 0000000000..023fdef3b9
--- /dev/null
+++ b/build/bin/check-port-availability.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+#
+# Licensed to the 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.
+# The 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.
+#
+
+source $(cd -P -- "$(dirname -- "$0")" && pwd -P)/header.sh
+
+
+# get port from configuraton
+kylin_port=`grep "<Connector port=" ${KYLIN_HOME}/tomcat/conf/server.xml |grep 
protocol=\"HTTP/1.1\" | cut -d '=' -f 2 | cut -d \" -f 2`
+
+# check the availability of the port
+kylin_port_in_use=`netstat -tlpn | grep "\b${kylin_port}\b"`
+
+# if not available, prompt error messeage
+[[ -z ${kylin_port_in_use} ]] || quit "ERROR: Port ${kylin_port} is in use, 
please check the availability of the port and re-start Kylin"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to