setup.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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-fatfree/index.php", "host=.*;", "host=" + args.database_host + ";")
  9. setup_util.replace_text("php-fatfree/deploy/php", "\".*\/FrameworkBenchmarks", "\"" + home + "/FrameworkBenchmarks")
  10. setup_util.replace_text("php-fatfree/deploy/php", "Directory .*\/FrameworkBenchmarks", "Directory " + home + "/FrameworkBenchmarks")
  11. setup_util.replace_text("php-fatfree/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  12. try:
  13. if os.name == 'nt':
  14. subprocess.check_call('appcmd add site /name:PHP /bindings:http/*:8080: /physicalPath:"C:\\FrameworkBenchmarks\\php-fatfree"', shell=True)
  15. return 0
  16. #subprocess.check_call("sudo cp php-fatfree/deploy/php /etc/apache2/sites-available/", shell=True)
  17. #subprocess.check_call("sudo a2ensite php", shell=True)
  18. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  19. subprocess.check_call("sudo chown -R www-data:www-data php-fatfree", shell=True)
  20. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php-fatfree/deploy/php-fpm.pid", shell=True)
  21. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php-fatfree/deploy/nginx.conf", shell=True)
  22. return 0
  23. except subprocess.CalledProcessError:
  24. return 1
  25. def stop():
  26. try:
  27. if os.name == 'nt':
  28. subprocess.check_call('appcmd delete site PHP', shell=True)
  29. return 0
  30. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  31. subprocess.call("sudo kill -QUIT $( cat php-fatfree/deploy/php-fpm.pid )", shell=True)
  32. subprocess.check_call("sudo chown -R $USER:$USER php-fatfree", shell=True)
  33. return 0
  34. except subprocess.CalledProcessError:
  35. return 1