setup_jruby.py 1.7 KB

1234567891011121314151617181920212223242526272829
  1. import subprocess
  2. import sys
  3. import setup_util
  4. def start(args, logfile):
  5. setup_util.replace_text("rails/config/database-jruby.yml", "host: .*", "host: " + args.database_host)
  6. setup_util.replace_text("rails/resin-web.xml", "mysql:\/\/.*:3306", "mysql://" + args.database_host + ":3306")
  7. try:
  8. subprocess.check_call("rvm jruby-1.7.4 do bundle install --gemfile=Gemfile-jruby", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  9. subprocess.check_call("cp Gemfile-jruby Gemfile", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  10. subprocess.check_call("cp Gemfile-jruby.lock Gemfile.lock", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  11. subprocess.check_call("cp config/database-jruby.yml config/database.yml", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  12. subprocess.check_call("rvm jruby-1.7.4 do warble war", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  13. subprocess.check_call("rm -rf $RESIN_HOME/webapps/*", shell=True, stderr=logfile, stdout=logfile)
  14. subprocess.check_call("cp rails.war $RESIN_HOME/webapps/rails.war", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  15. subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True, stderr=logfile, stdout=logfile)
  16. return 0
  17. except subprocess.CalledProcessError:
  18. return 1
  19. def stop(logfile):
  20. try:
  21. subprocess.check_call("$RESIN_HOME/bin/resinctl shutdown", shell=True, stderr=logfile, stdout=logfile)
  22. subprocess.check_call("rm Gemfile", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  23. subprocess.check_call("rm Gemfile.lock", shell=True, cwd="rails", stderr=logfile, stdout=logfile)
  24. return 0
  25. except subprocess.CalledProcessError:
  26. return 1