setup_nginx.py 991 B

1234567891011121314151617181920212223242526
  1. import subprocess
  2. import multiprocessing
  3. import os
  4. bin_dir = os.path.expanduser('~/FrameworkBenchmarks/installs/py2/bin')
  5. config_dir = os.path.expanduser('~/FrameworkBenchmarks/config')
  6. NCPU = multiprocessing.cpu_count()
  7. def start(args):
  8. try:
  9. subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c ' +
  10. config_dir + '/nginx_uwsgi.conf', shell=True)
  11. # Run in the background, but keep stdout/stderr for easy debugging.
  12. # Note that this uses --gevent 1000 just like setup.py.
  13. subprocess.Popen(bin_dir + '/uwsgi --ini ' + config_dir + '/uwsgi.ini' +
  14. ' --processes ' + str(NCPU) +
  15. ' --gevent 1000 --wsgi hello',
  16. shell=True, cwd='uwsgi')
  17. return 0
  18. except subprocess.CalledProcessError:
  19. return 1
  20. def stop():
  21. subprocess.call('sudo /usr/local/nginx/sbin/nginx -s stop', shell=True)
  22. subprocess.call(bin_dir + '/uwsgi --ini ' + config_dir + '/uwsgi_stop.ini', shell=True)
  23. return 0