setup.py 950 B

12345678910111213141516171819202122232425262728293031
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text('dart/postgresql.yaml', 'host: .*', 'host: ' + args.database_host)
  7. try:
  8. #
  9. # install dart dependencies
  10. #
  11. subprocess.check_call('pub upgrade', shell=True, cwd='dart', stderr=errfile, stdout=logfile)
  12. #
  13. # start dart servers
  14. #
  15. subprocess.Popen('dart server.dart -a 0.0.0.0 -p 8080 -d ' + str(args.max_concurrency) + ' -i ' + str(args.max_threads), shell=True, cwd='dart', stderr=errfile, stdout=logfile)
  16. return 0
  17. except subprocess.CalledProcessError:
  18. return 1
  19. def stop(logfile, errfile):
  20. #
  21. # stop dart servers
  22. #
  23. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  24. out, err = p.communicate()
  25. for line in out.splitlines():
  26. if 'dart' in line and 'run-tests' not in line and 'run-ci' not in line:
  27. pid = int(line.split(None, 2)[1])
  28. os.kill(pid, 15)
  29. return 0