setup.py 992 B

1234567891011121314151617181920212223242526272829
  1. import subprocess
  2. import setup_util
  3. from os.path import expanduser
  4. import os
  5. home = expanduser("~")
  6. def start(args, logfile, errfile):
  7. setup_util.replace_text("dropwizard/hello-world.yml", "url: jdbc:mysql://.*/hello_world",
  8. "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,
  12. cwd="dropwizard", stderr=errfile, stdout=logfile)
  13. return 0
  14. except subprocess.CalledProcessError:
  15. return 1
  16. def stop(logfile, errfile):
  17. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  18. out, err = p.communicate()
  19. for line in out.splitlines():
  20. if 'hello-world' in line:
  21. pid = int(line.split(None, 2)[1])
  22. os.kill(pid, 15)
  23. return 0