Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 b374fd593 -> 0396efc41
  refs/heads/cassandra-2.1.0 83ac8a631 -> 946050371
  refs/heads/trunk 93c9fb82c -> 461962866


improve Windows launch scripts
patch by Ala' Alkhaldi and Josh McKenzie for CASSANDRA-7503


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/94605037
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/94605037
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/94605037

Branch: refs/heads/cassandra-2.1
Commit: 9460503713891048fbd26549538d9215b8828f52
Parents: 83ac8a6
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Mon Jul 14 07:48:03 2014 -0500
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Mon Jul 14 07:48:03 2014 -0500

----------------------------------------------------------------------
 bin/cassandra.bat |  3 ++-
 bin/cassandra.ps1 | 48 ++++++------------------------------------------
 2 files changed, 8 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/94605037/bin/cassandra.bat
----------------------------------------------------------------------
diff --git a/bin/cassandra.bat b/bin/cassandra.bat
index 8f645f2..08c0520 100644
--- a/bin/cassandra.bat
+++ b/bin/cassandra.bat
@@ -35,8 +35,9 @@ goto runLegacy
 REM 
-----------------------------------------------------------------------------
 :runPowerShell
 echo Detected powershell execution permissions.  Running with enhanced startup 
scripts.
+set errorlevel=
 powershell /file "%CASSANDRA_HOME%\bin\cassandra.ps1" %*
-goto finally
+exit /b %errorlevel%
 
 REM 
-----------------------------------------------------------------------------
 :runLegacy

http://git-wip-us.apache.org/repos/asf/cassandra/blob/94605037/bin/cassandra.ps1
----------------------------------------------------------------------
diff --git a/bin/cassandra.ps1 b/bin/cassandra.ps1
index 237c28c..53b0032 100644
--- a/bin/cassandra.ps1
+++ b/bin/cassandra.ps1
@@ -47,7 +47,7 @@ usage: cassandra.ps1 [-f] [-h] [-p pidfile] [-H dumpfile] [-E 
errorfile] [-insta
     -f              Run cassandra in foreground
     -install        install cassandra as a service
     -uninstall      remove cassandra service
-    -p              pidfile tracked by server and removed on close
+    -p              pidfile tracked by server and removed on close (defaults 
to pid.txt)
     -H              change JVM HeapDumpPath
     -E              change JVM ErrorFile
     -help           print this message
@@ -109,7 +109,6 @@ Function Main
     }
     else
     {
-        CleanOldRun
         RunCassandra($f)
     }
 }
@@ -186,34 +185,6 @@ Function HandleInstallation
 }
 
 #-----------------------------------------------------------------------------
-Function CleanOldRun
-{
-    # see if we already have an instance of cassandra running from this folder
-    if (Test-Path $pidfile)
-    {
-        $a = Get-Content $pidfile
-
-        # file is there but empty
-        if ($a -eq $null)
-        {
-            Remove-Item $pidfile
-            return
-        }
-
-        $proc = Get-Process -Id $a -ErrorAction SilentlyContinue
-        if ($proc)
-        {
-            echo "ERROR!  There is already an instance of cassandra running 
from this folder with pid: $a.  Please use stop-server.bat to stop this 
instance before starting cassandra."
-            exit
-        }
-        else
-        {
-            Remove-Item $pidfile
-        }
-    }
-}
-
-#-----------------------------------------------------------------------------
 Function RunCassandra([string]$foreground)
 {
     echo "Starting cassandra server"
@@ -275,8 +246,8 @@ $env:JAVA_BIN
     {
         $proc = Start-Process -FilePath "$cmd" -ArgumentList 
$arg1,$arg2,$arg3,$arg4 -PassThru -WindowStyle Hidden
 
-        # Always store the pid, even if we're not registering it with the 
server
-        # The startup script uses this pid file as a protection against 
duplicate startup from the same folder
+        $exitCode = $?
+
         try
         {
             echo $proc.Id > $pidfile
@@ -287,19 +258,12 @@ $env:JAVA_BIN
 WARNING! Failed to write pidfile to $pidfile.  stop-server.bat and
     startup protection will not be available.
 "@
+            exit 1
         }
 
-        Start-Sleep -m 100
-        $checkProcess = Get-Process -Id $proc.Id -ErrorAction SilentlyContinue
-        if ($checkProcess -eq $null)
-        {
-            echo "Error starting cassandra."
-            echo "Run with -v and -f to get foreground verbose information on 
the error."
-        }
-        else
+        if (-Not $exitCode)
         {
-            $cassPid = $proc.Id
-            echo "Started cassandra successfully with pid: $cassPid"
+            exit 1
         }
     }
 }

Reply via email to