setup.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334
  1. import subprocess
  2. import sys
  3. import setup_util
  4. from os.path import expanduser
  5. home = expanduser("~")
  6. def start(args, logfile, errfile):
  7. setup_util.replace_text("php-pimf/app/config.app.php", "127.0.0.1", "" + args.database_host + "")
  8. setup_util.replace_text("php-pimf/deploy/php-pimf", "\".*\/FrameworkBenchmarks", "\"" + home + "/FrameworkBenchmarks")
  9. setup_util.replace_text("php-pimf/deploy/php-pimf", "Directory .*\/FrameworkBenchmarks", "Directory " + home + "/FrameworkBenchmarks")
  10. setup_util.replace_text("php-pimf/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  11. try:
  12. #subprocess.check_call("sudo cp cake/deploy/cake /etc/apache2/sites-available/", shell=True)
  13. #subprocess.check_call("sudo a2ensite cake", shell=True)
  14. #subprocess.check_call("sudo chown -R www-data:www-data cake", shell=True)
  15. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  16. subprocess.check_call("composer.phar install --optimize-autoloader", shell=True, cwd="php-pimf")
  17. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php-pimf/deploy/php-fpm.pid", shell=True)
  18. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php-pimf/deploy/nginx.conf", shell=True)
  19. return 0
  20. except subprocess.CalledProcessError:
  21. return 1
  22. def stop(logfile, errfile):
  23. try:
  24. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  25. subprocess.call("sudo kill -QUIT $( cat php-pimf/deploy/php-fpm.pid )", shell=True)
  26. #subprocess.check_call("sudo a2dissite cake", shell=True)
  27. #subprocess.check_call("sudo /etc/init.d/apache2 stop", shell=True)
  28. #subprocess.check_call("sudo chown -R $USER:$USER cake", shell=True)
  29. return 0
  30. except subprocess.CalledProcessError:
  31. return 1