From 6e7a22317537ba5026b00374af4e50f055e9c4eb Mon Sep 17 00:00:00 2001 From: Joshua McKenzie Date: Fri, 5 Dec 2014 14:19:28 -0600 Subject: [PATCH] Clean up string handling in powershell launch, check for JMX_PORT env var Patch by jmckenzie; reviewed by pthompson for CASSANDRA-8423 --- bin/cassandra.ps1 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/cassandra.ps1 b/bin/cassandra.ps1 index 3884fa597d..80049ee786 100644 --- a/bin/cassandra.ps1 +++ b/bin/cassandra.ps1 @@ -269,6 +269,7 @@ $env:JAVA_BIN WARNING! Failed to write pidfile to $pidfile. stop-server.bat and startup protection will not be available. "@ + echo $_.Exception.Message exit 1 } @@ -292,8 +293,8 @@ Function VerifyPortsAreAvailable $toMatch = @("storage_port:","ssl_storage_port:","native_transport_port:","rpc_port") $yaml = Get-Content "$env:CASSANDRA_CONF\cassandra.yaml" - $listenAddress = "unknown" - $rpcAddress = "unknown" + $listenAddress = "" + $rpcAddress = "" foreach ($line in $yaml) { if ($line -match "^listen_address:") @@ -307,14 +308,14 @@ Function VerifyPortsAreAvailable $rpcAddress = $args[1] -replace " ", "" } } - if ($listenAddress -eq "unknown") + if ([string]::IsNullOrEmpty($listenAddress)) { - echo "Failed to parse listen_address from cassandra.yaml to check open ports. Aborting startup." + Write-Error "Failed to parse listen_address from cassandra.yaml to check open ports. Aborting startup." Exit } - if ($rpcAddress -eq "unknown") + if ([string]::IsNullOrEmpty($rpcAddress)) { - echo "Failed to parse rpc_address from cassandra.yaml to check open ports. Aborting startup." + Write-Error "Failed to parse rpc_address from cassandra.yaml to check open ports. Aborting startup." Exit } @@ -335,6 +336,11 @@ Function VerifyPortsAreAvailable } } } + if ([string]::IsNullOrEmpty($env:JMX_PORT)) + { + Write-Error "No JMX_PORT is set in environment. Aborting startup." + Exit + } CheckPort $listenAddress "jmx_port: $env:JMX_PORT" }