setup.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. from os.path import expanduser
  6. home = expanduser("~")
  7. def start(args):
  8. setup_util.replace_text("php-codeigniter/application/config/database.php", "localhost", ""+ args.database_host +"")
  9. setup_util.replace_text("php-codeigniter/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  10. try:
  11. if os.name == 'nt':
  12. subprocess.check_call('icacls "C:\\FrameworkBenchmarks\\php-codeigniter" /grant "IIS_IUSRS:(OI)(CI)F"', shell=True)
  13. subprocess.check_call('appcmd add site /name:PHP /bindings:http/*:8080: /physicalPath:"C:\\FrameworkBenchmarks\\php-codeigniter"', shell=True)
  14. return 0
  15. subprocess.check_call("sudo chown -R www-data:www-data php-codeigniter", shell=True)
  16. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php-codeigniter/deploy/php-fpm.pid", shell=True)
  17. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php-codeigniter/deploy/nginx.conf", shell=True)
  18. return 0
  19. except subprocess.CalledProcessError:
  20. return 1
  21. def stop():
  22. try:
  23. if os.name == 'nt':
  24. subprocess.call('appcmd delete site PHP', shell=True)
  25. return 0
  26. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  27. subprocess.call("sudo kill -QUIT $( cat php-codeigniter/deploy/php-fpm.pid )", shell=True)
  28. subprocess.check_call("sudo chown -R $USER:$USER php-codeigniter", shell=True)
  29. return 0
  30. except subprocess.CalledProcessError:
  31. return 1