integrated startup sequence controlled by netcat
This commit is contained in:
@@ -79,4 +79,39 @@ if [ -n "$GANGLIA_HOST" ]; then
|
||||
done > /etc/hadoop/hadoop-metrics2.properties
|
||||
fi
|
||||
|
||||
function wait_for_it()
|
||||
{
|
||||
local serviceport=$1
|
||||
local service=${serviceport%%:*}
|
||||
local port=${serviceport#*:}
|
||||
local retry_seconds=5
|
||||
local max_try=100
|
||||
let i=1
|
||||
|
||||
nc -z $service $port
|
||||
result=$?
|
||||
|
||||
until [ $result -eq 0 ]; do
|
||||
echo "[$i/$max_try] check for ${service}:${port}..."
|
||||
echo "[$i/$max_try] ${service}:${port} is not available yet"
|
||||
if (( $i == $max_try )); then
|
||||
echo "[$i/$max_try] ${service}:${port} is still not available; giving up after ${max_try} tries. :/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[$i/$max_try] try in ${retry_seconds}s once again ..."
|
||||
let "i++"
|
||||
sleep $retry_seconds
|
||||
|
||||
nc -z $service $port
|
||||
result=$?
|
||||
done
|
||||
echo "[$i/$max_try] $service:${port} is available."
|
||||
}
|
||||
|
||||
for i in "${SERVICE_PRECONDITION[@]}"
|
||||
do
|
||||
wait_for_it ${i}
|
||||
done
|
||||
|
||||
exec $@
|
||||
|
||||
Reference in New Issue
Block a user