setup_jruby.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. import subprocess
  2. import sys
  3. import re
  4. import os
  5. def start(args, logfile, errfile):
  6. try:
  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.Popen("rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  10. return 0
  11. except subprocess.CalledProcessError:
  12. return 1
  13. def stop(logfile, errfile):
  14. try:
  15. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  16. out, err = p.communicate()
  17. for line in out.splitlines():
  18. if 'torqbox' in line:
  19. pid = int(line.split(None, 2)[1])
  20. os.kill(pid, 15)
  21. subprocess.check_call("rm -f Gemfile", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  22. subprocess.check_call("rm -f Gemfile.lock", shell=True, cwd="rack", stderr=errfile, stdout=logfile)
  23. return 0
  24. except subprocess.CalledProcessError:
  25. return 1