setup.py 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("servlet/src/main/webapp/WEB-INF/resin-web.xml", "localhost", args.database_host)
  7. try:
  8. subprocess.check_call("mvn clean compile war:war", shell=True, cwd="servlet", stderr=errfile, stdout=logfile)
  9. if os.name == 'nt':
  10. subprocess.check_call("rmdir /s /q C:\\Java\\resin\\webapps", shell=True, stderr=errfile, stdout=logfile)
  11. subprocess.check_call("mkdir C:\\Java\\resin\\webapps", shell=True, stderr=errfile, stdout=logfile)
  12. subprocess.check_call("cp servlet\\target\\servlet.war C:\\Java\\resin\\webapps\\servlet.war", shell=True, stderr=errfile, stdout=logfile)
  13. subprocess.check_call("C:\\Java\\resin\\bin\\start.bat", shell=True, stderr=errfile, stdout=logfile)
  14. return 0
  15. subprocess.check_call("rm -rf $RESIN_HOME/webapps/*", shell=True, stderr=errfile, stdout=logfile)
  16. subprocess.check_call("cp servlet/target/servlet.war $RESIN_HOME/webapps/", shell=True, stderr=errfile, stdout=logfile)
  17. subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True, stderr=errfile, stdout=logfile)
  18. return 0
  19. except subprocess.CalledProcessError:
  20. return 1
  21. def stop(logfile, errfile):
  22. try:
  23. if os.name == 'nt':
  24. subprocess.check_call("C:\\Java\\resin\\bin\\stop.bat", shell=True, stderr=errfile, stdout=logfile)
  25. return 0
  26. subprocess.check_call("$RESIN_HOME/bin/resinctl shutdown", shell=True, stderr=errfile, stdout=logfile)
  27. return 0
  28. except subprocess.CalledProcessError:
  29. return 1