setup.py 905 B

123456789101112131415161718192021222324
  1. import subprocess
  2. import sys
  3. import setup_util
  4. def start(args):
  5. setup_util.replace_text("restexpress/config/dev/environment.properties", "mysql:\/\/.*:3306", "mysql://" + args.database_host + ":3306")
  6. try:
  7. subprocess.check_call("mvn clean package", shell=True, cwd="restexpress")
  8. subprocess.check_call("mvn assembly:single", shell=True, cwd="restexpress")
  9. subprocess.check_call("unzip world-1.0-SNAPSHOT-zip-with-dependencies.zip", shell=True, cwd="restexpress/target")
  10. subprocess.Popen("java -jar world-1.0-SNAPSHOT.jar".rsplit(" "), cwd="restexpress/target/world-1.0-SNAPSHOT")
  11. return 0
  12. except subprocess.CalledProcessError:
  13. return 1
  14. def stop():
  15. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  16. out, err = p.communicate()
  17. for line in out.splitlines():
  18. if 'hello.Main' in line:
  19. pid = int(line.split(None, 2)[1])
  20. os.kill(pid, 9)
  21. return 0