setup.py 1.5 KB

123456789101112131415161718192021222324252627
  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-zend-framework1/application/configs/application.ini", "host = \"localhost\"", "host = \"" + args.database_host + "\"")
  8. setup_util.replace_text("php-zend-framework1/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  9. try:
  10. subprocess.check_call("composer.phar install", shell=True, cwd="php-zend-framework1", stderr=errfile, stdout=logfile)
  11. subprocess.check_call("sudo chown -R www-data:www-data php-zend-framework1", shell=True, stderr=errfile, stdout=logfile)
  12. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php-zend-framework1/deploy/php-fpm.pid", shell=True, stderr=errfile, stdout=logfile)
  13. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php-zend-framework1/deploy/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
  14. return 0
  15. except subprocess.CalledProcessError:
  16. return 1
  17. def stop(logfile, errfile):
  18. try:
  19. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True, stderr=errfile, stdout=logfile)
  20. subprocess.call("sudo kill -QUIT $( cat php-zend-framework1/deploy/php-fpm.pid )", shell=True, stderr=errfile, stdout=logfile)
  21. subprocess.check_call("sudo chown -R $USER:$USER php-zend-framework1", shell=True, stderr=errfile, stdout=logfile)
  22. return 0
  23. except subprocess.CalledProcessError:
  24. return 1