Skip to content

Commit 920df6f

Browse files
committed
Update setup_cassandra.sh
1 parent 92fc05d commit 920df6f

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

install/setup_cassandra.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,27 @@ if [ "$DISTRIB_RELEASE" == "24.04" ]; then
4646
apt-get install -y python3-six || true
4747
fi
4848

49-
cqlsh -e "CREATE KEYSPACE IF NOT EXISTS tippr WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};" || true
49+
# Verify Cassandra is actually accepting connections before running cqlsh.
50+
# If this fails the keyspace will be silently missing and the app will 404.
51+
echo "Verifying Cassandra CQL port is open before running setup..."
52+
if ! nc -z localhost 9042 2>/dev/null; then
53+
echo "ERROR: Cassandra is not listening on port 9042 — cannot set up schema." >&2
54+
echo "Start Cassandra first, wait for it to be ready, then re-run setup_cassandra.sh" >&2
55+
exit 1
56+
fi
57+
58+
cqlsh -e "CREATE KEYSPACE IF NOT EXISTS tippr WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};"
59+
if [ $? -ne 0 ]; then
60+
echo "ERROR: Failed to create tippr keyspace in Cassandra." >&2
61+
exit 1
62+
fi
5063

5164
# Create permacache table
52-
cqlsh -e "CREATE TABLE IF NOT EXISTS tippr.permacache (key text PRIMARY KEY, value blob);" || true
65+
cqlsh -e "CREATE TABLE IF NOT EXISTS tippr.permacache (key text PRIMARY KEY, value blob);"
66+
if [ $? -ne 0 ]; then
67+
echo "ERROR: Failed to create tippr.permacache table." >&2
68+
exit 1
69+
fi
5370

5471
echo "Cassandra keyspace and tables created."
5572

0 commit comments

Comments
 (0)