mirror of
https://github.com/apache/impala.git
synced 2025-12-25 11:04:13 -05:00
The shutdown script should not abort if it can't write a log - it should continue to try and shut down impala. The entrypoint script should abort with an explicit error if the log directory isn't writable by the current user. Change-Id: If32d6eef75422b51f8877478bbfb1a709c02f756 Reviewed-on: http://gerrit.cloudera.org:8080/16237 Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Reviewed-by: Attila Jeges <attilaj@cloudera.com> Reviewed-by: Andrew Sherman <asherman@cloudera.com>
61 lines
2.0 KiB
Bash
Executable File
61 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# 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.
|
|
|
|
# This script will send a signal to all impalad processes as identified by their name to
|
|
# initiate a graceful shutdown. It will then wait for a configurable amount time to allow
|
|
# the daemons to shutdown. The script will not forcefully terminate them, which is left to
|
|
# the orchestration framework.
|
|
|
|
set -euxo pipefail
|
|
|
|
export IMPALA_HOME=${IMPALA_HOME:-"/opt/impala"}
|
|
LOG_FILE="$IMPALA_HOME/logs/shutdown.log"
|
|
|
|
function LOG() {
|
|
# IMPALA-10006: append to LOG_FILE if possible, but don't fail if the log file isn't
|
|
# writable.
|
|
echo $* | tee -a $LOG_FILE || true
|
|
}
|
|
|
|
# Default grace timeout is the same as the default for Impala (-shutdown_grace_period_s),
|
|
# plus some additional safety buffer.
|
|
GRACE_TIMEOUT=$((120 + 10))
|
|
if [[ $# -ge 1 ]]; then
|
|
GRACE_TIMEOUT=$1
|
|
fi
|
|
|
|
LOG "Initiating graceful shutdown."
|
|
for pid in $(pgrep impalad); do
|
|
LOG "Sending signal to daemon with pid $pid"
|
|
kill -SIGRTMIN $pid
|
|
done
|
|
|
|
LOG "Waiting for daemons to exit, up to $GRACE_TIMEOUT s."
|
|
for ((i=0; i<$GRACE_TIMEOUT; ++i)); do
|
|
pids=$(pgrep impalad || true)
|
|
if [[ -z "$pids" ]]; then
|
|
LOG "All daemons have exited after $i s."
|
|
break
|
|
else
|
|
LOG "Daemons still running after $i s: $pids"
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
LOG "Graceful shutdown process complete."
|