setup.py 678 B

1234567891011121314151617181920212223
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args):
  6. setup_util.replace_text("django-stripped/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
  7. subprocess.Popen("gunicorn hello.wsgi:application -k gevent -b 0.0.0.0:8080 -w " + str((args.max_threads * 2)) + " --log-level=critical", shell=True, cwd="django-stripped/hello")
  8. return 0
  9. def stop():
  10. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  11. out, err = p.communicate()
  12. for line in out.splitlines():
  13. if 'gunicorn' in line:
  14. try:
  15. pid = int(line.split(None, 2)[1])
  16. os.kill(pid, 9)
  17. except OSError:
  18. pass
  19. return 0