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-phalcon/app/config/config.php", "mongodb:\/\/localhost", "mongodb://" + args.database_host)
  8. setup_util.replace_text("php-phalcon/app/config/config.php", "localhost", ""+ args.database_host +"")
  9. setup_util.replace_text("php-phalcon/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  10. try:
  11. subprocess.check_call("sudo chown -R www-data:www-data php-phalcon", shell=True, stderr=errfile, stdout=logfile)
  12. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php-phalcon/deploy/php-fpm.pid", shell=True, stderr=errfile, stdout=logfile)
  13. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php-phalcon/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-phalcon/deploy/php-fpm.pid )", shell=True, stderr=errfile, stdout=logfile)
  21. subprocess.check_call("sudo chown -R $USER:$USER php-phalcon", shell=True, stderr=errfile, stdout=logfile)
  22. return 0
  23. except subprocess.CalledProcessError:
  24. return 1