Skip to content

Commit 93cc0d5

Browse files
committed
fix localhost issue.
1 parent ded35a7 commit 93cc0d5

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

WebUI/Server/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ async def wrap_done(fn: Awaitable, event: asyncio.Event):
2828
# Signal the aiter to stop.
2929
event.set()
3030

31+
def getlocalip(host : str = "127.0.0.1"):
32+
if host == "0.0.0.0":
33+
return "127.0.0.1"
34+
return host
35+
3136
def fschat_controller_address() -> str:
3237
host = FSCHAT_CONTROLLER["host"]
3338
if host == "0.0.0.0":
@@ -209,7 +214,7 @@ def get_model_worker_config(model_name: str = None) -> dict:
209214
webui_config = configinst.dump()
210215
server_config = webui_config.get("ServerConfig")
211216

212-
config["host"] = server_config.get("default_host_ip")
217+
config["host"] = getlocalip(server_config.get("default_host_ip"))
213218
config["port"] = server_config["fastchat_model_worker"]["default"].get("port")
214219
config["vllm_enable"] = server_config["fastchat_model_worker"]["default"].get("vllm_enable")
215220

@@ -250,7 +255,7 @@ def get_vtot_worker_config(model_name: str = None) -> dict:
250255
configinst = InnerJsonConfigWebUIParse()
251256
webui_config = configinst.dump()
252257
server_config = webui_config.get("ServerConfig")
253-
config["host"] = server_config.get("default_host_ip")
258+
config["host"] = getlocalip(server_config.get("default_host_ip"))
254259
config["port"] = server_config["vtot_model_worker"].get("port")
255260

256261
if model_name is None or model_name == "":
@@ -282,7 +287,7 @@ def get_speech_worker_config(model_name: str = None) -> dict:
282287
configinst = InnerJsonConfigWebUIParse()
283288
webui_config = configinst.dump()
284289
server_config = webui_config.get("ServerConfig")
285-
config["host"] = server_config.get("default_host_ip")
290+
config["host"] = getlocalip(server_config.get("default_host_ip"))
286291
config["port"] = server_config["ttov_model_worker"].get("port")
287292

288293
if model_name is None or model_name == "":
@@ -314,7 +319,7 @@ def get_image_recognition_worker_config(model_name: str = None) -> dict:
314319
configinst = InnerJsonConfigWebUIParse()
315320
webui_config = configinst.dump()
316321
server_config = webui_config.get("ServerConfig")
317-
config["host"] = server_config.get("default_host_ip")
322+
config["host"] = getlocalip(server_config.get("default_host_ip"))
318323
config["port"] = server_config["image_recognition_worker"].get("port")
319324

320325
if model_name is None or model_name == "":
@@ -340,7 +345,7 @@ def get_image_generation_worker_config(model_name: str = None) -> dict:
340345
configinst = InnerJsonConfigWebUIParse()
341346
webui_config = configinst.dump()
342347
server_config = webui_config.get("ServerConfig")
343-
config["host"] = server_config.get("default_host_ip")
348+
config["host"] = getlocalip(server_config.get("default_host_ip"))
344349
config["port"] = server_config["image_generation_worker"].get("port")
345350

346351
if model_name is None or model_name == "":

WebUI/configs/serverconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
OPEN_CROSS_DOMAIN = False
1414

1515
# The server will listen on all available network interfaces.
16-
DEFAULT_BIND_HOST = "127.0.0.1"
16+
DEFAULT_BIND_HOST = "0.0.0.0"
1717

1818
#webui server
1919
WEBUI_SERVER = {

WebUI/configs/webuiconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@
912912
}
913913
},
914914
"ServerConfig": {
915-
"default_host_ip": "127.0.0.1",
915+
"default_host_ip": "0.0.0.0",
916916
"default_timeout": 300,
917917
"load_timeout": 120,
918918
"release_timeout": 60,

webuisrv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ def __init__(self):
99
def launch(self, started_event: mp.Event = None, run_mode: str = None):
1010
host = WEBUI_SERVER["host"]
1111
port = WEBUI_SERVER["port"]
12+
if host == "0.0.0.0":
13+
host = "localhost"
1214

1315
cmd = ["streamlit", "run", "webui.py",
1416
"--server.address", host,

0 commit comments

Comments
 (0)