Github user zhangh43 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/1109#discussion_r100270470
  
    --- 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 --
    
    Got it. When server is down, curl --fail will return 22. When server is up, 
it return 0 successfully.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to