setup.py 513 B

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