setup.py 849 B

1234567891011121314151617181920212223
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args, logfile, errfile):
  6. try:
  7. subprocess.check_call("mvn clean package", shell=True, cwd="spring", stderr=errfile, stdout=logfile)
  8. subprocess.Popen(("java -Ddatabase.host=" + args.database_host + " -jar spring.war").rsplit(" "), cwd="spring/target", stderr=errfile, stdout=logfile)
  9. return 0
  10. except subprocess.CalledProcessError:
  11. return 1
  12. def stop(logfile, errfile):
  13. if os.name == 'nt':
  14. subprocess.check_call("wmic process where \"CommandLine LIKE '%spring%'\" call terminate", stderr=errfile, stdout=logfile)
  15. else:
  16. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  17. out, err = p.communicate()
  18. for line in out.splitlines():
  19. if 'spring.war' in line:
  20. pid = int(line.split(None, 2)[1])
  21. os.kill(pid, 15)
  22. return 0