setup.py 985 B

1234567891011121314151617181920212223242526
  1. import multiprocessing
  2. import subprocess
  3. import os
  4. uwsgi = os.path.expandvars('$PY2_ROOT/bin/uwsgi')
  5. PROCS = multiprocessing.cpu_count()
  6. def start(args, logfile, errfile):
  7. # --http and --http-processes create http router processes that process the
  8. # incoming connections and pass them to the worker processes (-p). We use
  9. # PROCS number of http router processes so that a single router process
  10. # doesn't become a bottleneck.
  11. subprocess.Popen(
  12. uwsgi + ' --master -L -l 5000 --gevent 1000 --http :8080 --http-keepalive ' +
  13. ' --http-processes ' + str(PROCS) + ' -p ' + str(PROCS) + ' -w hello ' +
  14. ' --add-header "Connection: keep-alive" ' +
  15. ' --pidfile /tmp/uwsgi.pid',
  16. shell=True, cwd="uwsgi", stderr=errfile, stdout=logfile)
  17. return 0
  18. def stop(logfile, errfile):
  19. subprocess.call(uwsgi + ' --stop /tmp/uwsgi.pid', shell=True, cwd="uwsgi", stderr=errfile, stdout=logfile)
  20. os.system('killall uwsgi')
  21. return 0