setup.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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-fatfree/index.php", "localhost", ""+ args.database_host +"")
  7. setup_util.replace_text("php-fatfree/deploy/php", "\".*\/FrameworkBenchmarks/php-fatfree", "\"" + args.troot)
  8. setup_util.replace_text("php-fatfree/deploy/php", "Directory .*\/FrameworkBenchmarks/php-fatfree", "Directory " + args.troot)
  9. setup_util.replace_text("php-fatfree/deploy/nginx.conf", "root .*\/FrameworkBenchmarks/php-fatfree", "root " + args.troot)
  10. try:
  11. if os.name == 'nt':
  12. subprocess.check_call('appcmd add site /name:PHP /bindings:http/*:8080: /physicalPath:"C:\\FrameworkBenchmarks\\php-fatfree"', shell=True, stderr=errfile, stdout=logfile)
  13. return 0
  14. #subprocess.check_call("sudo cp php-fatfree/deploy/php /etc/apache2/sites-available/", shell=True)
  15. #subprocess.check_call("sudo a2ensite php", shell=True)
  16. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  17. subprocess.check_call("sudo chown -R www-data:www-data php-fatfree", shell=True, stderr=errfile, stdout=logfile)
  18. subprocess.check_call("sudo chmod -R 775 $TROOT/tmp/", shell=True, stderr=errfile, stdout=logfile)
  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.check_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. subprocess.check_call("sudo chown -R $USER:$USER php-fatfree", shell=True, stderr=errfile, stdout=logfile)
  32. return 0
  33. except subprocess.CalledProcessError:
  34. return 1