| # 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="chunkserver" |
| DESC="QFS Chunkserver" |
| PROC_NAME="chunkserver" |
| EXEC_PATH="/usr/bin/${PROC_NAME}" |
| SVC_USER="qfs" |
| WORKING_DIR="/var/lib/qfs" |
| CONF_DIR="/etc/qfs" |
| CONF_FILE="ChunkServer.prp" |
| LOGFILE="/var/log/qfs/${DAEMON}.log" |
| PIDFILE="/var/run/qfs/${DAEMON}.pid" |
| |
| generate_start() { |
| |
| cat <<'__EOT__' |
| start() { |
| [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED |
| log_success_msg "Starting $DESC ($DAEMON): " |
| |
| checkstatusofproc |
| status=$? |
| if [ "$status" -eq "$STATUS_RUNNING" ]; then |
| log_success_msg "$DESC is running" |
| exit 0 |
| fi |
| |
| echo "Starting $DESC: " |
| |
| # Debian doesn't like us to package anything inside /var/run. We create the |
| # directory here and set permissions as necessary for both debian and rpm |
| mkdir -p /var/run/qfs |
| chown qfs:qfs -R /var/run/qfs |
| chmod 755 /var/run/qfs |
| |
| runuser -s /bin/bash $SVC_USER -c "cd $WORKING_DIR && nohup $EXEC_PATH $CONF_DIR/$CONF_FILE > $LOGFILE 2>&1 < /dev/null & "'echo $! '"> $PIDFILE" |
| sleep 3 |
| |
| checkstatusofproc |
| RETVAL=$? |
| if [ $RETVAL -eq $STATUS_RUNNING ]; then |
| touch $LOCKFILE |
| log_success_msg "Starting $DESC (${DAEMON}): " |
| else |
| log_failure_msg "Failure to start $DESC (${DAEMON}). Return value: $RETVAL" |
| fi |
| return $RETVAL |
| } |
| __EOT__ |
| |
| } |
| |
| generate_stop() { |
| |
| cat <<'__EOT__' |
| stop() { |
| checkstatusofproc |
| if [ "$?" = "$STATUS_RUNNING" ] ; then |
| if [ -f $PIDFILE ]; then |
| PID=`cat $PIDFILE` |
| if [ -n $PID ]; then |
| kill -TERM $PID &>/dev/null |
| 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 |
| return $RETVAL |
| } |
| |
| __EOT__ |
| |
| } |