setup.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import setup_util
  2. import subprocess
  3. import sys
  4. import time
  5. import os
  6. def start(args, logfile, errfile):
  7. setup_util.replace_text('scruffy/src/main/scala/scruffy/examples/Test2Endpoint.scala', 'database_host', args.database_host)
  8. if os.name == 'nt':
  9. subprocess.check_call('"..\\sbt\\sbt.bat" assembly', shell=True, cwd="scruffy", stderr=errfile, stdout=logfile)
  10. else:
  11. subprocess.check_call(args.iroot + "/sbt/bin/sbt assembly", shell=True, cwd="scruffy", stderr=errfile, stdout=logfile)
  12. subprocess.Popen("java -jar target/scala-2.11/scruffy-benchmark-assembly-1.0.1.jar -Dhostname=" + args.database_host,
  13. cwd="scruffy",
  14. shell=True,
  15. stderr=errfile,
  16. stdout=logfile)
  17. return 0
  18. def stop(logfile, errfile):
  19. if os.name == 'nt':
  20. subprocess.check_call("wmic process where \"CommandLine LIKE '%scruffy-benchmark%'\" call terminate", stderr=errfile, stdout=logfile)
  21. else:
  22. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  23. out, err = p.communicate()
  24. for line in out.splitlines():
  25. if 'scruffy-benchmark' in line:
  26. try:
  27. pid = int(line.split(None, 2)[1])
  28. os.kill(pid, 15)
  29. except OSError:
  30. pass
  31. return 0