setup_raw.py 1.2 KB

12345678910111213141516171819202122232425
  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_raw.conf", "root .*\/FrameworkBenchmarks/php-pimf", "root " + args.troot)
  9. try:
  10. subprocess.check_call("composer.phar install --optimize-autoloader", shell=True, cwd="php-pimf")
  11. subprocess.check_call("sudo $PHP_FPM --fpm-config $FWROOT/config/php-fpm.conf -g $TROOT/deploy/php-fpm.pid", shell=True)
  12. subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/deploy/nginx_raw.conf", shell=True)
  13. return 0
  14. except subprocess.CalledProcessError:
  15. return 1
  16. def stop(logfile, errfile):
  17. try:
  18. subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
  19. subprocess.call("sudo kill -QUIT $( cat $TROOT/deploy/php-fpm.pid )", shell=True)
  20. return 0
  21. except subprocess.CalledProcessError:
  22. return 1