setup.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. from os.path import expanduser
  6. def start(args, logfile, errfile):
  7. fwroot = args.fwroot
  8. setup_util.replace_text("cakephp/app/Config/database.php", "'host' => '.*',", "'host' => '" + args.database_host + "',")
  9. setup_util.replace_text("cakephp/deploy/cake", "\".*\/FrameworkBenchmarks", "\"%s" % fwroot)
  10. setup_util.replace_text("cakephp/deploy/cake", "Directory .*\/FrameworkBenchmarks", "Directory %s" % fwroot)
  11. setup_util.replace_text("cakephp/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root %s" % fwroot)
  12. try:
  13. if os.name == 'nt':
  14. setup_util.replace_text("cakephp/app/Config/core.php", "'Apc'", "'Wincache'")
  15. subprocess.check_call('icacls "C:\\FrameworkBenchmarks\\cakephp" /grant "IIS_IUSRS:(OI)(CI)F"', shell=True, stderr=errfile, stdout=logfile)
  16. subprocess.check_call('appcmd add site /name:PHP /bindings:http/*:8080: /physicalPath:"C:\\FrameworkBenchmarks\\cakephp\\app\\webroot"', shell=True, stderr=errfile, stdout=logfile)
  17. return 0
  18. #subprocess.check_call("sudo cp cake/deploy/cake /etc/apache2/sites-available/", shell=True)
  19. #subprocess.check_call("sudo a2ensite cake", shell=True)
  20. subprocess.check_call("sudo chown -R www-data:www-data cakephp", shell=True, stderr=errfile, stdout=logfile)
  21. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  22. subprocess.check_call("sudo php-fpm --fpm-config $FWROOT/config/php-fpm.conf -g $TROOT/deploy/php-fpm.pid", shell=True, stderr=errfile, stdout=logfile)
  23. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/deploy/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
  24. return 0
  25. except subprocess.CalledProcessError:
  26. return 1
  27. def stop(logfile, errfile):
  28. try:
  29. if os.name == 'nt':
  30. subprocess.call('appcmd delete site PHP', shell=True, stderr=errfile, stdout=logfile)
  31. return 0
  32. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True, stderr=errfile, stdout=logfile)
  33. subprocess.call("sudo kill -QUIT $( cat $TROOT/deploy/php-fpm.pid )", shell=True, stderr=errfile, stdout=logfile)
  34. #subprocess.check_call("sudo a2dissite cake", shell=True)
  35. #subprocess.check_call("sudo /etc/init.d/apache2 stop", shell=True)
  36. subprocess.check_call("sudo chown -R $USER:$USER cakephp", shell=True, stderr=errfile, stdout=logfile)
  37. return 0
  38. except subprocess.CalledProcessError:
  39. return 1