setup.py 594 B

123456789101112131415161718192021222324
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args, logfile, errfile):
  6. db_host = args.database_host
  7. threads = str(args.max_threads)
  8. subprocess.Popen("racket -t bench.rkt -- " + db_host, shell=True, cwd="racket-ws/bench", stderr=errfile, stdout=logfile)
  9. return 0
  10. def stop(logfile, errfile):
  11. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  12. out, err = p.communicate()
  13. for line in out.splitlines():
  14. if 'bench' in line:
  15. try:
  16. pid = int(line.split(None, 2)[1])
  17. os.kill(pid, 15)
  18. except OSError:
  19. pass
  20. return 0