Github user zhangh43 commented on a diff in the pull request:
https://github.com/apache/incubator-hawq/pull/1109#discussion_r100222596
--- Diff: ranger-plugin/scripts/rps.sh ---
@@ -20,41 +20,71 @@
#
if [ $# -le 0 ]; then
- echo "Usage: rps (start|stop|init) [<catalina-args...>]"
+ echo "Usage: rps.sh (start|stop)"
exit 1
fi
-actionCmd=$1
+action=$1
shift
-CWDIR=$( cd $( dirname ${BASH_SOURCE[0]} ) && pwd )
-source $CWDIR/rps_env.sh
-
-setup_rps() {
- echo "Initializing Hawq Ranger Plugin Service..."
- cp $CATALINA_HOME/conf.template/* $CATALINA_BASE/conf
- cp $CATALINA_BASE/conf/tomcat-server.xml $CATALINA_BASE/conf/server.xml
- pushd $CATALINA_BASE/webapps >/dev/null
- unzip -d rps rps.war >/dev/null
- find . -name ranger-hawq-security.xml | xargs sed -i \
- "s/localhost:6080/$RANGER_ADMIN_HOST:$RANGER_ADMIN_PORT/g"
- popd >/dev/null
- echo "Hawq Ranger Plugin Service installed on
http://$RPS_HOST:$RPS_PORT/rps"
- echo "Please use 'rps.sh start' to start the service"
+CWDIR=$( cd $( dirname ${BASH_SOURCE[0]} ) && pwd -P)
+BASEDIR=$( dirname ${CWDIR} )
+# read properties from the file
+source ${BASEDIR}/etc/rps.properties
+
+export CATALINA_HOME=/usr/lib/bigtop-tomcat
+export CATALINA_BASE=${BASEDIR}/plugin-service
+export CATALINA_PID=${CATALINA_BASE}/work/rps.pid
+
+# options used to start the RPS process
+export CATALINA_OPTS="-server -Xms512m -Xmx512m -XX:MaxPermSize=128m
+ -Dproc_rps -Dversion=${RPS_VERSION}
+ -Dranger.hawq.instance=${RANGER_HAWQ_INSTANCE}
+ -Drps.http.port=${RPS_HTTP_PORT}
-Drps.https.port=${RPS_HTTPS_PORT}
+ -Dpolicy.manager.url=${POLICY_MGR_URL}"
+
+# options used to stop the RPS process
+export JAVA_OPTS="-Drps.shutdown.port=${RPS_SHUTDOWN_PORT}"
+
+RPS_URL="http://localhost:${RPS_HTTP_PORT}/rps"
+RPS_LOG="${CATALINA_BASE}/logs/catalina.out"
+
+function fail() {
+ echo "FATAL: Failed to ${1} HAWQ Ranger Plugin Service. Check
${RPS_LOG} for details."
+ exit 2
}
-case $actionCmd in
- (init)
- setup_rps
- ;;
+function tomcat_command() {
+ ${CWDIR}/catalina.sh ${1} ${2}
+ if [ $? -ne 0 ]; then
+ fail ${1}
+ fi
+}
+
+function wait_until_server_started() {
+ echo -n "Waiting for Hawq Ranger Plugin Service to start ."
+ local retries="20"
+ local n=0
+ until $(curl -s --output /dev/null --fail ${RPS_URL}/version); do
--- End diff --
The --fail option should be removed, its return code is 22.
Since the logic here is to repeat waiting if rps is not ready. When RPS is
ready, return code should be 0, and until statement returns.
curl -s --output /dev/null --fail ${Right_RPS_URL}/version
echo $? => 22
curl -s --output /dev/null ${Right_RPS_URL}/version
echo $? => 0
curl -s --output /dev/null --fail ${Wrong_RPS_URL}/version
echo $? => 7
curl -s --output /dev/null ${Right_RPS_URL}/version
echo $? => 7
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---