setup.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("servlet3-cass/src/main/resources/application.properties", "localhost", args.database_host)
  7. try:
  8. subprocess.check_call("mvn clean compile war:war", shell=True, cwd="servlet3-cass", 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 servlet3-cass\\target\\servlet3-cass.war C:\\Java\\resin\\webapps\\servlet3-cass.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 servlet3-cass/target/servlet3-cass.war $RESIN_HOME/webapps/", shell=True, stderr=errfile, stdout=logfile)
  17. # subprocess.call("echo checking connection to TFB DB host: "+args.database_host, shell=True, stderr=errfile, stdout=logfile)
  18. # subprocess.call("for i in 1 2 3 4 5; do nc -vz "+args.database_host+" 9160 && echo 'C* ok' && break || echo 'waiting for C*'; sleep 2; if [ $i -eq '5' ]; then echo 'ERROR: failed to connect to Cassandra'; fi; done", shell=True, stderr=errfile, stdout=logfile)
  19. subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True, stderr=errfile, stdout=logfile)
  20. return 0
  21. except subprocess.CalledProcessError:
  22. return 1
  23. def stop(logfile, errfile):
  24. try:
  25. if os.name == 'nt':
  26. subprocess.check_call("C:\\Java\\resin\\bin\\stop.bat", shell=True, stderr=errfile, stdout=logfile)
  27. return 0
  28. subprocess.check_call("$RESIN_HOME/bin/resinctl shutdown", shell=True, stderr=errfile, stdout=logfile)
  29. return 0
  30. except subprocess.CalledProcessError:
  31. return 1