65f91f444f
This patch adds script for docker health check of Redis service. The script checks the service using RESP PING command. Change-Id: If6e4fba9da81350046630420e5bee0ee4cbd14cc
28 lines
838 B
Bash
28 lines
838 B
Bash
#!/bin/bash
|
|
|
|
if parse_out=$(cat "/etc/redis.conf" | egrep "^bind +.*$"); then
|
|
redis_host=$(echo -n $parse_out | awk '{print $2}')
|
|
else
|
|
redis_host=127.0.0.1
|
|
fi
|
|
|
|
if parse_out=$(cat "/etc/redis.conf" | egrep "^port +.*$"); then
|
|
redis_port=$(echo -n $parse_out | awk '{print $2}')
|
|
else
|
|
redis_port=6379
|
|
fi
|
|
|
|
if parse_out=$(cat "/etc/redis.conf" | egrep "^requirepass +.*$"); then
|
|
redis_pass=$(echo -n $parse_out | awk '{print $2}')
|
|
result=$(printf "*2\r\n\$4\r\nAUTH\r\n\$${#redis_pass}\r\n${redis_pass}\r\n*1\r\n\$4\r\nPING\r\n" | nc $redis_host $redis_port)
|
|
else
|
|
result=$(printf "*1\r\n\$4\r\nPING\r\n" | nc $redis_host $redis_port)
|
|
fi
|
|
|
|
if echo $result | grep -q '+PONG'; then
|
|
echo "Redis server responded correctly on ${redis_host}:${redis_port}."
|
|
else
|
|
echo "Redis server does not respond correctly: ${result}"
|
|
exit 1
|
|
fi
|