I'm writing a simple function to test whether Cassandra is running on the local machine (by capturing the output of service cassandra status
. The problem is that this command always exits with a bad return status of 3. I have successfully called service cassandra stop
immediately prior to this command, and have even tried running status
in a loop to see if there was some race condition (it seems to reliably fail with status 3 for a long time). However, running service cassandra status
through the shell works. Any ideas what the issue may be, or even just how to debug this?
private def isCassandraStopped(): Boolean = {
val s = Seq("sudo", "sh", "-c", "service cassandra status").!!
val r = " * Cassandra is not running" == s
if (!r) logger.info(s"Cassandra is not stopped: #$s#")
r
}
This is the line that succeeds prior to executing the above method:
Seq("sudo", "sh", "-c", "service cassandra stop").!