setup_jruby.py 1.3 KB

1234567891011121314151617181920212223242526
  1. import subprocess
  2. import sys
  3. import re
  4. def start(args, logfile, errfile):
  5. try:
  6. subprocess.check_call("rvm jruby-1.7.4 do bundle install --gemfile=Gemfile-jruby", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  7. subprocess.check_call("cp Gemfile-jruby Gemfile", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  8. subprocess.check_call("cp Gemfile-jruby.lock Gemfile.lock", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  9. subprocess.check_call("rvm jruby-1.7.4 do warble war", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  10. subprocess.check_call("rm -rf $RESIN_HOME/webapps/*", shell=True, stderr=errfile, stdout=logfile)
  11. subprocess.check_call("cp rack.war $RESIN_HOME/webapps/rack.war", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  12. subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True, stderr=errfile, stdout=logfile)
  13. return 0
  14. except subprocess.CalledProcessError:
  15. return 1
  16. def stop(logfile, errfile):
  17. try:
  18. subprocess.check_call("$RESIN_HOME/bin/resinctl shutdown", shell=True, stderr=errfile, stdout=logfile)
  19. subprocess.check_call("rm Gemfile", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  20. subprocess.check_call("rm Gemfile.lock", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  21. return 0
  22. except subprocess.CalledProcessError:
  23. return 1