setup.py 1006 B

1234567891011121314151617181920212223242526272829
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args):
  6. setup_util.replace_text("django/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
  7. # for the love of all that is good and right in the universe, use gevent worker
  8. # if you're going to bother to use gunicorn. meinheld is faster, but needs some work on
  9. # certain asynch support.
  10. # $ easy_install pip
  11. # $ pip install gevent
  12. # not so difficult, is it?
  13. # requires 5 minutes of searching
  14. # so much for CTO Outsourcing
  15. 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/hello")
  16. return 0
  17. def stop():
  18. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  19. out, err = p.communicate()
  20. for line in out.splitlines():
  21. if 'gunicorn' in line:
  22. try:
  23. pid = int(line.split(None, 2)[1])
  24. os.kill(pid, 9)
  25. except OSError:
  26. pass
  27. return 0