| # 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. |
| |
| DAEMON="zookeeper-rest" |
| DESC="ZooKeeper REST Server" |
| SVC_USER="${ZOOKEEPER_USER:-zookeeper}" |
| WORKING_DIR="/var/run/zookeeper" |
| DAEMON_FLAGS="" |
| CONF_DIR="/etc/zookeeper/conf/rest" |
| PIDFILE="/var/run/zookeeper/zookeeper-rest-$SVC_USER.pid" |
| |
| generate_start() { |
| |
| cat <<'__EOT__' |
| start() { |
| log_success_msg "Starting ${DESC}: " |
| |
| ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/lib/zookeeper} |
| CLASSPATH="${ZOOKEEPER_HOME}/contrib/rest/*:${ZOOKEEPER_HOME}/contrib/rest/lib/*" |
| CLASSPATH="${ZOOKEEPER_HOME}/*:${ZOOKEEPER_HOME}/lib/*:${CONF_DIR}:${CLASSPATH}" |
| CMD="${JAVA_HOME}/bin/java -cp ${CLASSPATH} org.apache.zookeeper.server.jersey.RestMain" |
| |
| LOG_FILE=/var/log/zookeeper/zookeeper-rest.out |
| |
| su -s /bin/bash -c "nohup ${CMD} > $LOG_FILE 2>&1 < /dev/null &"'echo $! '"> $PIDFILE" $SVC_USER |
| |
| [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE |
| return $RETVAL |
| } |
| __EOT__ |
| |
| } |
| |
| generate_stop() { |
| |
| cat <<'__EOT__' |
| stop() { |
| log_success_msg "Stopping ${DESC}: " |
| checkstatusofproc |
| if [ "$?" = "$STATUS_RUNNING" ] ; then |
| if [ -f ${PIDFILE} ]; then |
| PID=`cat ${PIDFILE}` |
| if [ -n ${PID} ]; then |
| kill -KILL ${PID} &>/dev/null |
| fi |
| fi |
| RETVAL=$? |
| else |
| RETVAL=$RETVAL_SUCCESS |
| fi |
| |
| [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE |
| } |
| __EOT__ |
| |
| } |