websoft9/appmanage/api/utils/network.py
2023-03-07 16:55:23 +08:00

16 lines
480 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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