Browse Source

Upgrade play-java and play-scala from Play 2.2.0 to 2.3.2

Rich Dougherty 11 years ago
parent
commit
7f6c7ec7ec

+ 1 - 1
play-java/build.sbt

@@ -2,4 +2,4 @@ name := "play-java"
 
 version := "1.0-SNAPSHOT"
 
-playJavaSettings
+lazy val root = (project in file(".")).enablePlugins(PlayJava)

+ 1 - 1
play-java/project/build.properties

@@ -1 +1 @@
-sbt.version=0.13.0
+sbt.version=0.13.5

+ 1 - 1
play-java/project/plugins.sbt

@@ -5,4 +5,4 @@ logLevel := Level.Warn
 resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
 
 // Use the Play sbt plugin for Play projects
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.2")

+ 27 - 4
play-java/setup.py

@@ -1,11 +1,34 @@
-import setup_util
+import os
+import signal
 import subprocess
 
+dirname = projname = 'play-java'
+is_windows = args.os.lower() == "windows"
+cmd_suffix = '.bat' if is_windows else ''
+
 def start(args, logfile, errfile):
-  subprocess.Popen(["play","start"], stdin=subprocess.PIPE, cwd="play-java", stderr=errfile, stdout=logfile)
+  kill_running_process() # Kill the running process and delete the 
+                         # RUNNING_PID file (if any). With any luck no 
+                         # new process has picked up the same PID.
+
+  subprocess.call(['sbt'+cmd_suffix,"stage"], stdin=subprocess.PIPE, cwd=dirname, stderr=errfile, stdout=logfile)
+  subprocess.Popen([os.path.join("target","universal","stage","bin",projname+cmd_suffix)], shell=True, stdin=subprocess.PIPE, cwd=dirname, stderr=errfile, stdout=logfile)
   return 0
 
 def stop(logfile, errfile):
-  p = subprocess.Popen(["play","stop"], cwd="play-java", stderr=errfile, stdout=logfile)
-  p.communicate()
+  kill_running_process()  
   return 0
+
+def kill_running_process():
+  pidfile = os.path.join(dirname,"target","universal","stage","RUNNING_PID")
+  try:
+    with open(pidfile) as f:
+      pid = int(f.read())
+      os.kill(pid, signal.SIGTERM)
+  except:
+    pass
+
+  try:
+    os.remove(pidfile)
+  except OSError:
+    pass

+ 1 - 1
play-scala/build.sbt

@@ -2,4 +2,4 @@ name := "play-scala"
 
 version := "1.0-SNAPSHOT"
 
-playScalaSettings
+lazy val root = (project in file(".")).enablePlugins(PlayScala)

+ 1 - 1
play-scala/project/build.properties

@@ -1 +1 @@
-sbt.version=0.13.0
+sbt.version=0.13.5

+ 1 - 1
play-scala/project/plugins.sbt

@@ -5,4 +5,4 @@ logLevel := Level.Warn
 resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
 
 // Use the Play sbt plugin for Play projects
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")
+addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.2")

+ 14 - 12
play-scala/setup.py

@@ -1,17 +1,18 @@
-import setup_util
-import subprocess
 import os
+import signal
+import subprocess
+
+dirname = projname = 'play-scala'
+is_windows = args.os.lower() == "windows"
+cmd_suffix = '.bat' if is_windows else ''
 
 def start(args, logfile, errfile):
   kill_running_process() # Kill the running process and delete the 
                          # RUNNING_PID file (if any). With any luck no 
                          # new process has picked up the same PID.
 
-  play_cmd = "play"
-  if args.os.lower() == "windows":
-    play_cmd = "play.bat"
-  
-  subprocess.Popen([play_cmd,"start"], stdin=subprocess.PIPE, cwd="play-scala", stderr=errfile, stdout=logfile)
+  subprocess.call(['sbt'+cmd_suffix,"stage"], stdin=subprocess.PIPE, cwd=dirname, stderr=errfile, stdout=logfile)
+  subprocess.Popen([os.path.join("target","universal","stage","bin",projname+cmd_suffix)], shell=True, stdin=subprocess.PIPE, cwd=dirname, stderr=errfile, stdout=logfile)
   return 0
 
 def stop(logfile, errfile):
@@ -19,14 +20,15 @@ def stop(logfile, errfile):
   return 0
 
 def kill_running_process():
+  pidfile = os.path.join(dirname,"target","universal","stage","RUNNING_PID")
   try:
-    with open("./play-scala/RUNNING_PID") as f:
+    with open(pidfile) as f:
       pid = int(f.read())
-      os.kill(pid, 15)
+      os.kill(pid, signal.SIGTERM)
   except:
-  	pass
+    pass
 
   try:
-    os.remove("play-scala/RUNNING_PID")
+    os.remove(pidfile)
   except OSError:
-    pass  
+    pass