setup.py 1.4 KB

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