setup_py3.py 742 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. import subprocess
  3. import sys
  4. import time
  5. CWD = os.path.dirname(__file__)
  6. def start(args, logfile, errfile):
  7. subprocess.Popen(
  8. "$PY3 server.py --port=8080 --mongo=%s --logging=error" % (args.database_host,),
  9. shell=True, cwd=CWD, stderr=errfile, stdout=logfile)
  10. return 0
  11. def stop(logfile, errfile):
  12. subprocess.call(
  13. 'pgrep -f server.py',
  14. shell=True, stderr=errfile, stdout=logfile)
  15. subprocess.call(
  16. 'pkill -f server.py',
  17. shell=True, stderr=errfile, stdout=logfile)
  18. time.sleep(1)
  19. if __name__ == '__main__':
  20. class DummyArg:
  21. database_host = 'localhost'
  22. start(DummyArg(), sys.stderr, sys.stderr)
  23. time.sleep(1)
  24. stop(sys.stderr, sys.stderr)