install-reddit: Use netcat to determine if services are up.

This is more robust than the previous method which slept for 30 seconds
and ended up being simultaneously optimistic and pessimistic.
This commit is contained in:
Neil Williams
2012-08-04 20:29:42 -07:00
parent 4a4543b38b
commit 5887e0898e

View File

@@ -148,6 +148,21 @@ cassandra
haproxy
PACKAGES
###############################################################################
# Wait for all the services to be up
###############################################################################
# check each port for connectivity
echo "Waiting for services to be available, see source for port meanings..."
# 11211 - memcache
# 5432 - postgres
# 5672 - rabbitmq
# 9160 - cassandra
for port in 11211 5432 5672 9160; do
while ! nc -vz localhost $port; do
sleep 1
done
done
###############################################################################
# Install the reddit source repositories
###############################################################################
@@ -169,9 +184,6 @@ fi
###############################################################################
# Configure Cassandra
###############################################################################
# wait a bit to make sure all the servers come up
sleep 30
if ! echo | cassandra-cli -h localhost -k reddit > /dev/null 2>&1; then
echo "create keyspace reddit;" | cassandra-cli -h localhost -B
fi