blob: 5bbd6165a8d2eae06a49526783b1ce84553f6661 [file] [log] [blame]
# 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.
TYPE="taskmanager"
DAEMON="flink-${TYPE}"
DESC="Flink ${TYPE}"
EXEC_PATH="/usr/lib/flink/bin/flink-daemon.sh"
WORKING_DIR="/var/lib/flink"
DAEMON_FLAGS="taskmanager"
SVC_USER="flink"
CONF_DIR="/etc/flink/conf"
PIDFILE="/var/run/flink/flink-$SVC_USER-taskmanager.pid"
generate_start() {
cat <<'__EOT__'
start() {
[ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED
log_success_msg "Starting $DESC (${DAEMON}): "
export FLINK_LOG_DIR="/var/log/flink"
export FLINK_PID_DIR="/var/run/flink"
mkdir -p $FLINK_PID_DIR
checkstatusofproc
status=$?
if [ "$status" -eq "$STATUS_RUNNING" ]; then
log_success_msg "${DESC} is running"
exit 0
fi
LOG_FILE=/var/log/flink/${DAEMON}.out
runuser -s /bin/bash $SVC_USER -c "nohup nice -n 0 \
${EXEC_PATH} start ${DAEMON_FLAGS} --configDir ${CONF_DIR} \
> $LOG_FILE 2>&1 & "
sleep 3
checkstatusofproc
RETVAL=$?
if [ $RETVAL -eq $STATUS_RUNNING ]; then
touch $LOCKFILE
log_success_msg "Started ${DESC} (${DAEMON}): "
else
log_failure_msg "Failed to start ${DESC}. Return value: $RETVAL"
fi
return $RETVAL
}
__EOT__
}
generate_stop() {
cat <<'__EOT__'
stop() {
log_success_msg "Stopping $DESC (${DAEMON}): "
killproc -p $PIDFILE java
RETVAL=$?
[ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE
return $RETVAL
}
__EOT__
}