Sfoglia il codice sorgente

Updated play-scala setup for Windows

Updated the play-scala setup.py file to work with Windows (i.e. call
`play.bat`).

Fixed issues with the `stop()` method [Play2 no longer supports the
`stop` command].
Kevin Pullin 12 anni fa
parent
commit
580f0a5268
1 ha cambiato i file con 24 aggiunte e 3 eliminazioni
  1. 24 3
      play-scala/setup.py

+ 24 - 3
play-scala/setup.py

@@ -1,12 +1,33 @@
 import setup_util
 import subprocess
+import os
 
 def start(args):
+  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"
+  
   setup_util.replace_text("play-scala/conf/application.conf", "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
-  subprocess.Popen(["play","start"], stdin=subprocess.PIPE, cwd="play-scala")
+  subprocess.Popen([play_cmd,"start"], stdin=subprocess.PIPE, cwd="play-scala")
   return 0
 
 def stop():
-  p = subprocess.Popen(["play","stop"], cwd="play-scala")
-  p.communicate()
+  kill_running_process()  
   return 0
+
+def kill_running_process():
+  try:
+    with open("./play-scala/RUNNING_PID") as f:
+      pid = int(f.read())
+      os.kill(pid, 9)
+  except:
+  	pass
+
+  try:
+    os.remove("play-scala/RUNNING_PID")
+  except OSError:
+    pass