setup.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("phreeze/index.php", "localhost:3306", "" + args.database_host + ":3306")
  7. setup_util.replace_text("phreeze/deploy/phreeze", "\".*\/FrameworkBenchmarks/phreeze", "\"" + args.troot)
  8. setup_util.replace_text("phreeze/deploy/phreeze", "Directory .*\/FrameworkBenchmarks/phreeze", "Directory " + args.troot)
  9. setup_util.replace_text("phreeze/deploy/nginx.conf", "root .*\/FrameworkBenchmarks/phreeze", "root " + args.troot)
  10. try:
  11. if os.name == 'nt':
  12. subprocess.check_call('icacls "C:\\FrameworkBenchmarks\\phreeze" /grant "IIS_IUSRS:(OI)(CI)F"', shell=True, stderr=errfile, stdout=logfile)
  13. subprocess.check_call('appcmd add site /name:PHP /bindings:http/*:8080: /physicalPath:"C:\\FrameworkBenchmarks\\phreeze"', shell=True, stderr=errfile, stdout=logfile)
  14. return 0
  15. #subprocess.check_call("sudo cp php/deploy/phreeze /etc/apache2/sites-available/", shell=True)
  16. #subprocess.check_call("sudo a2ensite php", shell=True)
  17. #subprocess.check_call("sudo chown -R www-data:www-data php", shell=True)
  18. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  19. subprocess.check_call("sudo $PHP_FPM --fpm-config $FWROOT/config/php-fpm.conf -g $TROOT/deploy/php-fpm.pid", shell=True, stderr=errfile, stdout=logfile)
  20. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/deploy/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
  21. return 0
  22. except subprocess.CalledProcessError:
  23. return 1
  24. def stop(logfile, errfile):
  25. try:
  26. if os.name == 'nt':
  27. subprocess.call('appcmd delete site PHP', shell=True, stderr=errfile, stdout=logfile)
  28. return 0
  29. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True, stderr=errfile, stdout=logfile)
  30. subprocess.call("sudo kill -QUIT $( cat $TROOT/deploy/php-fpm.pid )", shell=True, stderr=errfile, stdout=logfile)
  31. return 0
  32. except subprocess.CalledProcessError:
  33. return 1