setup.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. import time
  6. CWD = 'revel-jet'
  7. def start(args, logfile, errfile):
  8. setup_util.replace_text(CWD + "/src/benchmark/conf/app.conf", "tcp\(.*:3306\)", "tcp(" + args.database_host + ":3306)")
  9. if os.name == 'nt':
  10. env = os.environ.copy()
  11. env["GOPATH"] = "C:\\FrameworkBenchmarks\\" + CWD
  12. subprocess.call("go get -u github.com/robfig/revel/revel github.com/eaigner/jet", shell=True, cwd=CWD, env=env, stderr=errfile, stdout=logfile)
  13. subprocess.call(r"go build -o bin\revel.exe github.com/robfig/revel/revel", shell=True, cwd=CWD, env=env, stderr=errfile, stdout=logfile)
  14. subprocess.Popen(r"bin\revel.exe run benchmark prod".rsplit(" "), shell=True, cwd=CWD, env=env, stderr=errfile, stdout=logfile)
  15. return 0
  16. subprocess.call("go get -u github.com/robfig/revel/revel github.com/eaigner/jet", shell=True, cwd=CWD, stderr=errfile, stdout=logfile)
  17. subprocess.call("go build -o bin/revel github.com/robfig/revel/revel", shell=True, cwd=CWD, stderr=errfile, stdout=logfile)
  18. subprocess.Popen("bin/revel run benchmark prod".rsplit(" "), cwd=CWD, stderr=errfile, stdout=logfile)
  19. return 0
  20. def stop(logfile, errfile):
  21. if os.name == 'nt':
  22. subprocess.call("taskkill /f /im benchmark.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  23. subprocess.call("taskkill /f /im revel.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  24. return 0
  25. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  26. out, err = p.communicate()
  27. for line in out.splitlines():
  28. if 'revel' in line and 'run-tests' not in line:
  29. pid = int(line.split(None, 2)[1])
  30. os.kill(pid, 15)
  31. return 0