Github user denalex commented on a diff in the pull request:
https://github.com/apache/incubator-hawq/pull/1109#discussion_r100231177
--- 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 --
It works, I think when you tested you had RPS shut down. Curl returns error
7 if it can't connect to host. When RPS is up, the return is 0. See the trace
below:
bash-4.1# curl -s --output /dev/null --fail
http://localhost:8432/rps/version
bash-4.1# echo $?
7
bash-4.1# curl --fail http://localhost:8432/rps/version
curl: (7) couldn't connect to host
bash-4.1# ps aux | grep rps
root 2340 0.0 0.0 6500 464 ? R+ 04:58 0:00 grep rps
bash-4.1# ./rps.sh start
Using CATALINA_BASE: /usr/local/hawq_2_1_0_0/ranger/plugin-service
Using CATALINA_HOME: /usr/lib/bigtop-tomcat
Using CATALINA_TMPDIR: /usr/local/hawq_2_1_0_0/ranger/plugin-service/temp
Using JRE_HOME: /usr/lib/jvm/java-1.7.0-openjdk.x86_64
Using CLASSPATH:
/usr/local/hawq_2_1_0_0/ranger/etc:/usr/lib/bigtop-tomcat/bin/bootstrap.jar
Using CATALINA_PID:
/usr/local/hawq_2_1_0_0/ranger/plugin-service/work/rps.pid
Waiting for Hawq Ranger Plugin Service to start ..
Hawq Ranger Plugin Service is available at http://localhost:8432/rps
bash-4.1# curl -s --output /dev/null --fail
http://localhost:8432/rps/version
bash-4.1# echo $?
0
bash-4.1#
---
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.
---