setup.py 923 B

12345678910111213141516171819202122232425
  1. import subprocess
  2. import sys
  3. import setup_util
  4. from os.path import expanduser
  5. import os
  6. home = expanduser("~")
  7. def start(args, logfile, errfile):
  8. setup_util.replace_text("dropwizard/hello-world.yml", "url: jdbc:mysql://.*/hello_world", "url: jdbc:mysql://" + args.database_host + ":3306/hello_world")
  9. try:
  10. subprocess.check_call("mvn clean package;", shell=True, cwd="dropwizard", stderr=errfile, stdout=logfile)
  11. subprocess.Popen("java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world.yml", shell=True, cwd="dropwizard", stderr=errfile, stdout=logfile)
  12. return 0
  13. except subprocess.CalledProcessError:
  14. return 1
  15. def stop(logfile, errfile):
  16. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  17. out, err = p.communicate()
  18. for line in out.splitlines():
  19. if 'hello-world' in line:
  20. pid = int(line.split(None, 2)[1])
  21. os.kill(pid, 15)
  22. return 0