setup.py 1.0 KB

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