Permalink
Browse files

wait and test for redis to accept connections before returning OK in …

…start
  • Loading branch information...
michael-dev committed Sep 4, 2012
1 parent 73d3c07 commit 3f38e86f4c2a1cef57fb628b5ff0bcfa9d7990bc
Showing with 14 additions and 1 deletion.
  1. +14 −1 heartbeat/redis
View
@@ -426,11 +426,24 @@ redis_start() {
ocf_log err "$OCF_RESKEY_binary start command failed: $rc"
return $OCF_NOT_RUNNING
fi
- sleep 3
ocf_log info "$REDIS_SERVER_NAME started"
fi
+ # wait for redis to actually open the tcp port
+ # as redis starts but does not open this port if db files are corrupt
+ for i in $(seq 1 5); do
+ redis_cmd 0 info >/dev/null
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ sleep 1
+ done
+ redis_cmd 1 info >/dev/null
+ if [ $? -ne 0 ]; then
+ return $OCF_ERR_GENERIC
+ fi
+
if ocf_is_ms; then
# Now, let's see whether there is a master. We might be a new
# node that is just joining the cluster, and the CRM may have

0 comments on commit 3f38e86

Please sign in to comment.