@@ -55,25 +55,36 @@ if [ "$DISTRIB_RELEASE" == "24.04" ]; then
5555 apt-get install $APTITUDE_OPTIONS cassandra
5656
5757 # Enable and start Cassandra
58- sudo systemctl enable cassandra
59- sudo systemctl start cassandra
58+ systemctl enable cassandra
59+ systemctl start cassandra
6060
61- # Wait for Cassandra to be available (CQL native port 9042)
62- echo " Waiting for Cassandra to be available..."
61+ # Cassandra 4.1 on Ubuntu 24.04 uses a SysV init wrapper: systemctl reports
62+ # "active (exited)" immediately but the JVM forks in the background and
63+ # takes 60-180 s to open port 9042. Wait up to 5 minutes.
64+ echo " Waiting for Cassandra JVM to open port 9042 (up to 5 minutes)..."
6365 CASSANDRA_UP=0
64- for i in $( seq 1 60) ; do
66+ for i in $( seq 1 150) ; do
67+ # Bail early if the JVM died rather than spin the full 5 minutes
68+ if ! pgrep -f ' org.apache.cassandra' > /dev/null 2>&1 ; then
69+ echo " Cassandra JVM process is not running — startup failed early." >&2
70+ break
71+ fi
6572 if nc -z localhost 9042 2> /dev/null; then
66- echo " Cassandra is up!"
73+ echo " Cassandra is up! (attempt $i ) "
6774 CASSANDRA_UP=1
6875 break
6976 fi
70- echo " attempt $i /60 — not yet available, sleeping 2s..."
77+ echo " attempt $i /150 — not yet available, sleeping 2s..."
7178 sleep 2
7279 done
7380 if [ " $CASSANDRA_UP " = " 0" ]; then
74- echo " ERROR: Cassandra did not start within 120 seconds ." >&2
75- echo " Check systemd logs: journalctl -u cassandra --no-pager | tail -50 " >&2
81+ echo " ERROR: Cassandra did not start within expected time ." >&2
82+ echo " --- systemctl status --- " >&2
7683 systemctl status cassandra --no-pager || true
84+ echo " --- last 80 lines of /var/log/cassandra/system.log ---" >&2
85+ tail -80 /var/log/cassandra/system.log 2> /dev/null || true
86+ echo " --- journalctl -u cassandra (last 50 lines) ---" >&2
87+ journalctl -u cassandra --no-pager | tail -50 || true
7788 exit 1
7889 fi
7990
0 commit comments