setup.py 1.7 KB

12345678910111213141516171819202122232425262728293031
  1. import subprocess
  2. import sys
  3. import setup_util
  4. def start(args, logfile, errfile):
  5. setup_util.replace_text("php-pimf/app/config.app.php", "127.0.0.1", "" + args.database_host + "")
  6. setup_util.replace_text("php-pimf/deploy/php-pimf", "\".*\/FrameworkBenchmarks/php-pimf", "\"" + args.troot)
  7. setup_util.replace_text("php-pimf/deploy/php-pimf", "Directory .*\/FrameworkBenchmarks/php-pimf", "Directory " + args.troot)
  8. setup_util.replace_text("php-pimf/deploy/nginx.conf", "root .*\/FrameworkBenchmarks/php-pimf", "root " + args.troot)
  9. try:
  10. #subprocess.check_call("sudo cp cake/deploy/cake /etc/apache2/sites-available/", shell=True)
  11. #subprocess.check_call("sudo a2ensite cake", shell=True)
  12. #subprocess.check_call("sudo chown -R www-data:www-data cake", shell=True)
  13. #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
  14. subprocess.check_call("composer.phar install --optimize-autoloader", shell=True, cwd="php-pimf")
  15. subprocess.check_call("sudo $PHP_FPM --fpm-config $FWROOT/config/php-fpm.conf -g $TROOT/deploy/php-fpm.pid", shell=True)
  16. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/deploy/nginx.conf", shell=True)
  17. return 0
  18. except subprocess.CalledProcessError:
  19. return 1
  20. def stop(logfile, errfile):
  21. try:
  22. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  23. subprocess.call("sudo kill -QUIT $( cat $TROOT/deploy/php-fpm.pid )", shell=True)
  24. #subprocess.check_call("sudo a2dissite cake", shell=True)
  25. #subprocess.check_call("sudo /etc/init.d/apache2 stop", shell=True)
  26. #subprocess.check_call("sudo chown -R $USER:$USER cake", shell=True)
  27. return 0
  28. except subprocess.CalledProcessError:
  29. return 1