setup.py 1.2 KB

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