Browse Source

now PLAIN should run on Windows, too

weltermann17 11 years ago
parent
commit
bdf8fa8f0d
2 changed files with 67 additions and 5 deletions
  1. 55 0
      plain/sbt.bat
  2. 12 5
      plain/setup.py

+ 55 - 0
plain/sbt.bat

@@ -0,0 +1,55 @@
+@REM SBT launcher script
+@REM 
+@REM Envioronment:
+@REM JAVA_HOME - location of a JDK home dir (mandatory)
+@REM SBT_OPTS  - JVM options (optional)
+@REM Configuration:
+@REM sbtconfig.txt found in the SBT_HOME.
+
+@REM   ZOMG! We need delayed expansion to build up CFG_OPTS later 
+@setlocal enabledelayedexpansion
+
+@echo off
+set SBT_HOME=%~dp0
+set SBT_OPTS=-Xmx3g -Xms2g -Xmn1g -Xss8M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M
+set ERROR_CODE=0
+
+rem FIRST we load the config file of extra options.
+set FN=%SBT_HOME%\..\conf\sbtconfig.txt
+set CFG_OPTS=
+FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO (
+  set DO_NOT_REUSE_ME=%%i
+  rem ZOMG (Part #2) WE use !! here to delay the expansion of
+  rem CFG_OPTS, otherwise it remains "" for this loop.
+  set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME!
+)
+
+rem We use the value of the JAVACMD environment variable if defined
+set _JAVACMD=%JAVACMD%
+
+if "%_JAVACMD%"=="" (
+  if not "%JAVA_HOME%"=="" (
+    if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
+  )
+)
+
+if "%_JAVACMD%"=="" set _JAVACMD=java
+
+rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
+set _JAVA_OPTS=%JAVA_OPTS%
+if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS%
+
+:run
+
+"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+
+@endlocal
+
+exit /B %ERROR_CODE%

+ 12 - 5
plain/setup.py

@@ -4,14 +4,21 @@ import sys
 import time
 import time
 import os
 import os
 
 
-def start(args=None):
-    setup_util.replace_text("plain/src/main/resources/application.conf", "127.0.0.1", args.database_host)
+def start(args):
+  setup_util.replace_text("plain/src/main/resources/application.conf", "127.0.0.1", args.database_host)
+  if os.name == 'nt':
+    subprocess.check_call("./sbt.bat assembly", shell=True, cwd="plain")
+  else:
     subprocess.check_call("./sbt assembly", shell=True, cwd="plain")
     subprocess.check_call("./sbt assembly", shell=True, cwd="plain")
-    subprocess.Popen("java -server -Xnoclassgc -XX:MaxPermSize=1g -XX:ReservedCodeCacheSize=384m -Xmx8g -Xss8m -Xmn4g -jar target/scala-2.10/plain-benchmark-assembly-1.0.1.jar", cwd="plain", shell=True)
-    time.sleep(10)
-    return 0
+      
+  subprocess.Popen("java -server -Xnoclassgc -XX:MaxPermSize=1g -XX:ReservedCodeCacheSize=384m -Xmx8g -Xss8m -Xmn4g -jar target/scala-2.10/plain-benchmark-assembly-1.0.1.jar", cwd="plain", shell=True)
+  time.sleep(10)
+  return 0
 
 
 def stop():
 def stop():
+  if os.name == 'nt':
+    subprocess.call("taskkill /f /im *plain-benchmark* > NUL", shell=True)
+    return 0
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   out, err = p.communicate()
   out, err = p.communicate()
   for line in out.splitlines():
   for line in out.splitlines():