setup.py 997 B

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