setup.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. from os.path import expanduser
  6. home = expanduser("~")
  7. def start(args):
  8. setup_util.replace_text("php/dborm.php", "@.*\/hello_world", "@" + args.database_host + "/hello_world")
  9. setup_util.replace_text("php/dbraw.php", "host=.*;", "host=" + args.database_host + ";")
  10. setup_util.replace_text("php/deploy/php", "\".*\/FrameworkBenchmarks", "\"" + home + "/FrameworkBenchmarks")
  11. setup_util.replace_text("php/deploy/php", "Directory .*\/FrameworkBenchmarks", "Directory " + home + "/FrameworkBenchmarks")
  12. setup_util.replace_text("php/deploy/nginx.conf", "root .*\/FrameworkBenchmarks", "root " + home + "/FrameworkBenchmarks")
  13. try:
  14. #subprocess.check_call("sudo cp php/deploy/php /etc/apache2/sites-available/", shell=True)
  15. #subprocess.check_call("sudo a2ensite php", shell=True)
  16. #subprocess.check_call("sudo chown -R www-data:www-data php", shell=True)
  17. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  18. subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php/deploy/php-fpm.pid", shell=True)
  19. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php/deploy/nginx.conf", shell=True)
  20. return 0
  21. except subprocess.CalledProcessError:
  22. return 1
  23. def stop():
  24. try:
  25. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  26. subprocess.call("sudo kill -QUIT $( cat php/deploy/php-fpm.pid )", shell=True)
  27. return 0
  28. except subprocess.CalledProcessError:
  29. return 1