setup_py3.py 724 B

123456789101112131415161718192021222324252627282930
  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. if __name__ == '__main__':
  19. class DummyArg:
  20. database_host = 'localhost'
  21. start(DummyArg(), sys.stderr, sys.stderr)
  22. time.sleep(1)
  23. stop(sys.stderr, sys.stderr)