setup.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. import signal
  3. import subprocess
  4. dirname = projname = 'play-java'
  5. is_windows = args.os.lower() == "windows"
  6. cmd_suffix = '.bat' if is_windows else ''
  7. def start(args, logfile, errfile):
  8. kill_running_process() # Kill the running process and delete the
  9. # RUNNING_PID file (if any). With any luck no
  10. # new process has picked up the same PID.
  11. subprocess.call(['sbt'+cmd_suffix,"stage"], stdin=subprocess.PIPE, cwd=dirname, stderr=errfile, stdout=logfile)
  12. subprocess.Popen([os.path.join("target","universal","stage","bin",projname+cmd_suffix)], shell=True, stdin=subprocess.PIPE, cwd=dirname, 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. pidfile = os.path.join(dirname,"target","universal","stage","RUNNING_PID")
  19. try:
  20. with open(pidfile) as f:
  21. pid = int(f.read())
  22. os.kill(pid, signal.SIGTERM)
  23. except:
  24. pass
  25. try:
  26. os.remove(pidfile)
  27. except OSError:
  28. pass