setup.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. import subprocess
  2. import sys
  3. import setup_util
  4. import os
  5. def start(args, logfile, errfile):
  6. setup_util.replace_text("ringojs-convenient/app/models.js", "dbHost = '.*';", "dbHost = '" + args.database_host + "';")
  7. try:
  8. subprocess.check_call("sudo rm -rf /usr/share/ringojs/packages/*", shell=True, stderr=errfile, stdout=logfile)
  9. subprocess.check_call("sudo ringo-admin install oberhamsi/sql-ringojs-client", shell=True, stderr=errfile, stdout=logfile)
  10. subprocess.check_call("sudo ringo-admin install grob/ringo-sqlstore", shell=True, stderr=errfile, stdout=logfile)
  11. subprocess.check_call("sudo ringo-admin install ringo/stick", shell=True, stderr=errfile, stdout=logfile)
  12. subprocess.check_call("sudo ringo-admin install oberhamsi/reinhardt", shell=True, stderr=errfile, stdout=logfile)
  13. subprocess.check_call("sudo mkdir -p /usr/share/ringojs/packages/ringo-sqlstore/jars/", shell=True, stderr=errfile, stdout=logfile)
  14. subprocess.check_call("sudo cp /usr/share/ringojs//packages/sql-ringojs-client/jars/mysql.jar /usr/share/ringojs/packages/ringo-sqlstore/jars/", shell=True, stderr=errfile, stdout=logfile)
  15. subprocess.Popen("ringo --production -J-server -J-Xmx1g -J-Xms1g ringo-main.js", shell=True, cwd="ringojs-convenient", stderr=errfile, stdout=logfile)
  16. return 0
  17. except subprocess.CalledProcessError:
  18. return 1
  19. def stop(logfile, errfile):
  20. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  21. out, err = p.communicate()
  22. for line in out.splitlines():
  23. if 'ringo-main.js' in line:
  24. pid = int(line.split(None, 2)[1])
  25. try:
  26. os.kill(pid, 15)
  27. except OSError:
  28. pass
  29. return 0