setup.py 557 B

12345678910111213141516171819
  1. import subprocess
  2. import sys
  3. import os
  4. import setup_util
  5. def start(args):
  6. setup_util.replace_text("go/src/hello/hello.go", "tcp\(.*:3306\)", "tcp(" + args.database_host + ":3306)")
  7. subprocess.call("go get ./...", shell=True, cwd="go")
  8. subprocess.Popen("go run src/hello/hello.go".rsplit(" "), cwd="go")
  9. return 0
  10. def stop():
  11. p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
  12. out, err = p.communicate()
  13. for line in out.splitlines():
  14. if 'hello' in line:
  15. pid = int(line.split(None, 2)[1])
  16. os.kill(pid, 9)
  17. return 0