setup.py 1.4 KB

12345678910111213141516171819202122232425262728
  1. import subprocess
  2. import sys
  3. import setup_util
  4. from os.path import expanduser
  5. home = expanduser("~")
  6. def start(args):
  7. setup_util.replace_text("php-symfony2/app/config/parameters.yml", "database_host: .*", "database_host: " + args.database_host)
  8. setup_util.replace_text("php-symfony2/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  9. try:
  10. subprocess.check_call("composer.phar install --optimize-autoloader", shell=True, cwd="php-symfony2")
  11. subprocess.check_call("php app/console cache:clear --env=prod --no-debug", shell=True, cwd="php-symfony2")
  12. subprocess.check_call("sudo chown -R www-data:www-data php-symfony2", shell=True)
  13. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php-symfony2/deploy/php-fpm.pid", shell=True)
  14. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php-symfony2/deploy/nginx.conf", shell=True)
  15. return 0
  16. except subprocess.CalledProcessError:
  17. return 1
  18. def stop():
  19. try:
  20. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  21. subprocess.call("sudo kill -QUIT $( cat php-symfony2/deploy/php-fpm.pid )", shell=True)
  22. subprocess.check_call("sudo chown -R $USER:$USER php-symfony2", shell=True)
  23. return 0
  24. except subprocess.CalledProcessError:
  25. return 1