setup_ruby.py 1.1 KB

123456789101112131415161718192021222324
  1. import subprocess
  2. import sys
  3. import setup_util
  4. def start(args):
  5. setup_util.replace_text("sinatra/hello_world.rb", ":host => '.*'", ":host => '" + args.database_host + "'")
  6. try:
  7. subprocess.check_call("rvm ruby-2.0.0-p0 do bundle install --gemfile=Gemfile-ruby", shell=True, cwd="sinatra")
  8. subprocess.check_call("cp Gemfile-ruby Gemfile", shell=True, cwd="sinatra")
  9. subprocess.check_call("cp Gemfile-ruby.lock Gemfile.lock", shell=True, cwd="sinatra")
  10. subprocess.check_call("rvm ruby-2.0.0-p0 do bundle exec passenger start -p 8080 -d -e production --pid-file=$HOME/FrameworkBenchmarks/sinatra/sinatra.pid --nginx-version=1.2.7 --max-pool-size=24", shell=True, cwd="sinatra")
  11. return 0
  12. except subprocess.CalledProcessError:
  13. return 1
  14. def stop():
  15. try:
  16. subprocess.check_call("rvm ruby-2.0.0-p0 do bundle exec passenger stop --pid-file=$HOME/FrameworkBenchmarks/sinatra/sinatra.pid", shell=True, cwd='sinatra')
  17. subprocess.check_call("rm Gemfile", shell=True, cwd="sinatra")
  18. subprocess.check_call("rm Gemfile.lock", shell=True, cwd="sinatra")
  19. return 0
  20. except subprocess.CalledProcessError:
  21. return 1