setup.py 928 B

123456789101112131415161718192021222324252627282930313233
  1. import setup_util
  2. import subprocess
  3. import os
  4. def start(args, logfile, errfile):
  5. kill_running_process() # Kill the running process and delete the
  6. # RUNNING_PID file (if any). With any luck no
  7. # new process has picked up the same PID.
  8. play_cmd = "play"
  9. if args.os.lower() == "windows":
  10. play_cmd = "play.bat"
  11. setup_util.replace_text("play-scala/conf/application.conf", "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
  12. subprocess.Popen([play_cmd,"start"], stdin=subprocess.PIPE, cwd="play-scala", stderr=errfile, stdout=logfile)
  13. return 0
  14. def stop(logfile, errfile):
  15. kill_running_process()
  16. return 0
  17. def kill_running_process():
  18. try:
  19. with open("./play-scala/RUNNING_PID") as f:
  20. pid = int(f.read())
  21. os.kill(pid, 15)
  22. except:
  23. pass
  24. try:
  25. os.remove("play-scala/RUNNING_PID")
  26. except OSError:
  27. pass