setup.py 768 B

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