setup.py 1.4 KB

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