setup.py 1.3 KB

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