setup_jruby.py 1.1 KB

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