setup.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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. time.sleep(5)
  18. return 0
  19. def stop(logfile, errfile):
  20. if os.name == 'nt':
  21. subprocess.check_call("wmic process where \"CommandLine LIKE '%scruffy-benchmark%'\" call terminate", stderr=errfile, stdout=logfile)
  22. else:
  23. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  24. out, err = p.communicate()
  25. for line in out.splitlines():
  26. if 'scruffy-benchmark' in line:
  27. try:
  28. pid = int(line.split(None, 2)[1])
  29. os.kill(pid, 15)
  30. except OSError:
  31. pass
  32. return 0