| # 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="sqoop2-server" |
| DESC="Sqoop Server" |
| EXEC_PATH="/usr/bin/sqoop2-server" |
| SVC_USER="${SQOOP_USER:-sqoop2}" |
| WORKING_DIR="/var/lib/sqoop2" |
| DAEMON_FLAGS="" |
| CONF_DIR="${SQOOP_CONFIG:-/etc/sqoop2/conf}" |
| PIDFILE="${SQOOP_PID:-/var/run/sqoop2/sqoop-server-$SVC_USER.pid}" |
| |
| generate_functions() { |
| |
| cat <<'__EOT__' |
| sqoop_env() { |
| export SQOOP_CONFIG |
| export CATALINA_BASE |
| export CATALINA_BIN |
| export CATALINA_PID=$SQOOP_PID |
| export CATALINA_OPTS |
| export CATALINA_OUT |
| export CATALINA_TMPDIR |
| } |
| __EOT__ |
| |
| } |
| |
| generate_start() { |
| |
| cat <<'__EOT__' |
| start() { |
| [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED |
| [ -d $CONF_DIR ] || exit $ERROR_PROGRAM_NOT_CONFIGURED |
| log_success_msg "Starting ${DESC}: " |
| |
| sqoop_env |
| |
| su -s /bin/bash -c "cd ~/ && ${EXEC_PATH} start $DAEMON_FLAGS" $SVC_USER |
| |
| for second in {5..0} |
| do |
| checkstatusofproc |
| RETVAL=$? |
| if [ "$RETVAL" -eq $RETVAL_SUCCESS ] ; then |
| break |
| fi |
| sleep 1 |
| done |
| |
| [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE |
| return $RETVAL |
| } |
| __EOT__ |
| |
| } |
| |
| generate_stop() { |
| |
| cat <<'__EOT__' |
| stop() { |
| # FIXME: workaround for BIGTOP-537 |
| checkstatusofproc |
| if [ "$?" = "$STATUS_RUNNING" ] ; then |
| |
| sqoop_env |
| |
| su -s /bin/bash -c "cd ~/ && ${EXEC_PATH} stop" $SVC_USER |
| |
| SQOOP_SHUTDOWN_TIMEOUT=${SQOOP_SHUTDOWN_TIMEOUT:-60} |
| |
| if [ -f $PIDFILE ]; then |
| PID=`cat $PIDFILE` |
| if [ -n $PID ]; then |
| kill -TERM $PID &>/dev/null |
| for i in `seq 1 ${SQOOP_SHUTDOWN_TIMEOUT}` ; do |
| kill -0 ${SQOOP_PID} &>/dev/null || break |
| sleep 1 |
| done |
| if [ ! kill -0 ${SQOOP_PID} &>/dev/null ]; then |
| kill -KILL ${SQOOP_PID} &>/dev/null |
| fi |
| fi |
| fi |
| |
| RETVAL=$? |
| else |
| RETVAL=$RETVAL_SUCCESS |
| fi |
| |
| if [ $RETVAL -eq $RETVAL_SUCCESS ]; then |
| rm -f $LOCKFILE $PIDFILE |
| log_success_msg "Stopped ${DESC}: " |
| else |
| log_failure_msg "Failed to stop ${DESC}. Return value: $RETVAL" |
| fi |
| } |
| __EOT__ |
| |
| } |