setup.py 946 B

123456789101112131415161718192021222324252627
  1. import subprocess
  2. import sys
  3. import setup_util
  4. def start(args):
  5. try:
  6. subprocess.check_call("lein deps", shell=True, cwd="http-kit/hello")
  7. subprocess.check_call("rm -rf target", shell=True, cwd="http-kit/hello")
  8. # pack all dependencies into a single jar: target/http-kit-standalone.jar
  9. subprocess.check_call("lein uberjar", shell=True, cwd="http-kit/hello")
  10. # -server is much faster
  11. # 'lein run' passes '-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1' which make it starts fast, but runs slow
  12. command = "java -server -jar target/http-kit-standalone.jar --db-host " + args.database_host
  13. subprocess.Popen(command, shell=True, cwd="http-kit/hello")
  14. return 0
  15. except subprocess.CalledProcessError:
  16. return 1
  17. def stop():
  18. try:
  19. # listen on 8080
  20. subprocess.check_call("lsof -t -sTCP:LISTEN -i:8080 | xargs kill", shell=True)
  21. return 0
  22. except subprocess.CalledProcessError:
  23. return 1