network.py 519 B

12345678910111213141516
  1. import os, io, sys, platform, shutil, time, json, datetime
  2. from api.utils import shell_execute
  3. # 根据.env文件提供的port,找出能正常启动的最小port
  4. def get_start_port(port):
  5. use_port = port
  6. while True:
  7. print("check port: "+use_port)
  8. cmd = "netstat -ntlp | grep -v only"
  9. output = shell_execute.execute_command_output_all(cmd)
  10. if output["result"].find(use_port)==-1:
  11. break
  12. else:
  13. use_port = str(int(use_port)+1)
  14. return use_port