setup.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. import glob
  6. def start(args, logfile, errfile):
  7. setup_util.replace_text("scalatra/src/main/webapp/WEB-INF/resin-web.xml", "mysql:\/\/.*:3306", "mysql://" + args.database_host + ":3306")
  8. try:
  9. if os.name == 'nt':
  10. subprocess.check_call('"..\\sbt\\sbt.bat" clean package', shell=True, cwd="scalatra", stderr=errfile, stdout=logfile)
  11. subprocess.check_call('rmdir /S /Q "%RESIN_HOME%\\webapps\\"', shell=True, stderr=errfile, stdout=logfile)
  12. subprocess.check_call('mkdir "%RESIN_HOME%\\webapps\\"', shell=True, stderr=errfile, stdout=logfile)
  13. # 'copy' on windows doesn't like the wildcard war file selector
  14. warFile = glob.glob("scalatra\\target\\scala-2.10\\scalatra*.war")[0]
  15. subprocess.check_call('copy "{0}" "%RESIN_HOME%\\webapps\\scalatra.war"'.format(warFile), shell=True, stderr=errfile, stdout=logfile)
  16. subprocess.check_call('"%RESIN_HOME%\\bin\\start.bat"', shell=True, stderr=errfile, stdout=logfile)
  17. else:
  18. subprocess.check_call("../sbt/sbt clean package", shell=True, cwd="scalatra", stderr=errfile, stdout=logfile)
  19. subprocess.check_call("rm -rf $RESIN_HOME/webapps/*", shell=True, stderr=errfile, stdout=logfile)
  20. subprocess.check_call("cp scalatra/target/scala-2.10/scalatra*.war $RESIN_HOME/webapps/scalatra.war", shell=True, stderr=errfile, stdout=logfile)
  21. subprocess.check_call("$RESIN_HOME/bin/resinctl start", shell=True, stderr=errfile, stdout=logfile)
  22. return 0
  23. except subprocess.CalledProcessError:
  24. return 1
  25. def stop(logfile, errfile):
  26. try:
  27. if os.name == 'nt':
  28. subprocess.check_call('"%RESIN_HOME%\\bin\\stop.bat"', shell=True, stderr=errfile, stdout=logfile)
  29. else:
  30. subprocess.check_call("$RESIN_HOME/bin/resinctl shutdown", shell=True, stderr=errfile, stdout=logfile)
  31. return 0
  32. except subprocess.CalledProcessError:
  33. return 1