network.py 508 B

1234567891011121314151617
  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. print("目前检查"+port+"是否被占用")
  6. use_port = port
  7. output = "ok"
  8. while True:
  9. cmd = "netstat -anp|grep "+use_port
  10. output = shell_execute.execute_CommandReturn(cmd)
  11. if output == "":
  12. break
  13. else:
  14. use_port = use_port+1
  15. return use_port