setup.py 1.1 KB

1234567891011121314151617181920212223242526
  1. import subprocess
  2. import sys
  3. import os
  4. def start(args, logfile, errfile):
  5. if os.name == 'nt':
  6. subprocess.call("set GOPATH=C:\\FrameworkBenchmarks\\webgo&&go get ./...", shell=True, cwd="webgo", stderr=errfile, stdout=logfile)
  7. subprocess.Popen("setup.bat", shell=True, cwd="webgo", stderr=errfile, stdout=logfile)
  8. return 0
  9. os.environ["GOPATH"] = os.path.expanduser('~/FrameworkBenchmarks/webgo')
  10. subprocess.call("go get ./...", shell=True, cwd="webgo", stderr=errfile, stdout=logfile)
  11. subprocess.Popen("go run src/hello/hello.go".rsplit(" "), cwd="webgo", stderr=errfile, stdout=logfile)
  12. return 0
  13. def stop(logfile, errfile):
  14. if os.name == 'nt':
  15. subprocess.call("taskkill /f /im go.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  16. subprocess.call("taskkill /f /im hello.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
  17. return 0
  18. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  19. out, err = p.communicate()
  20. for line in out.splitlines():
  21. if 'hello' in line:
  22. pid = int(line.split(None, 2)[1])
  23. os.kill(pid, 15)
  24. return 0