setup.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("php/dborm.php", "@.*\/hello_world", "@" + args.database_host + "/hello_world")
  7. setup_util.replace_text("php/dbraw.php", "host=.*;", "host=" + args.database_host + ";")
  8. setup_util.replace_text("php/updateraw.php", "host=.*;", "host=" + args.database_host + ";")
  9. setup_util.replace_text("php/fortune.php", "host=.*;dbname", "host=" + args.database_host + ";dbname")
  10. setup_util.replace_text("php/deploy/php", "\".*\/FrameworkBenchmarks/php", "\"" + args.troot)
  11. setup_util.replace_text("php/deploy/php", "Directory .*\/FrameworkBenchmarks/php", "Directory " + args.troot)
  12. setup_util.replace_text("php/deploy/nginx.conf", "root .*\/FrameworkBenchmarks/php", "root " + args.troot)
  13. try:
  14. if os.name == 'nt':
  15. subprocess.check_call('appcmd add site /name:PHP /bindings:http/*:8080: /physicalPath:"C:\\FrameworkBenchmarks\\php"', shell=True, stderr=errfile, stdout=logfile)
  16. return 0
  17. #subprocess.check_call("sudo cp php/deploy/php /etc/apache2/sites-available/", shell=True)
  18. #subprocess.check_call("sudo a2ensite php", shell=True)
  19. #subprocess.check_call("sudo chown -R www-data:www-data php", shell=True)
  20. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  21. 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)
  22. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/deploy/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
  23. return 0
  24. except subprocess.CalledProcessError:
  25. return 1
  26. def stop(logfile, errfile):
  27. try:
  28. if os.name == 'nt':
  29. subprocess.check_call('appcmd delete site PHP', shell=True, stderr=errfile, stdout=logfile)
  30. return 0
  31. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True, stderr=errfile, stdout=logfile)
  32. subprocess.call("sudo kill -QUIT $( cat $TROOT/deploy/php-fpm.pid )", shell=True, stderr=errfile, stdout=logfile)
  33. return 0
  34. except subprocess.CalledProcessError:
  35. return 1