Compare commits

...

3 Commits

Author SHA1 Message Date
Jeff Wainwright
6c7fa0870c
Merge e0c6b59d39 into 5943fbf457 2026-01-08 09:56:41 -08:00
Dr.Lt.Data
5943fbf457
bump comfyui_manager version to the 4.0.5 (#11732)
Some checks are pending
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
2026-01-08 08:15:42 -08:00
Jeff Wainwright
e0c6b59d39 fix: use random port for desktop/standalone builds to avoid port conflicts 2025-08-25 14:37:25 -07:00
4 changed files with 41 additions and 2 deletions

View File

@ -1,6 +1,8 @@
import argparse
import enum
import os
import socket
import sys
import comfy.options
@ -36,7 +38,7 @@ class EnumAction(argparse.Action):
parser = argparse.ArgumentParser()
parser.add_argument("--listen", type=str, default="127.0.0.1", metavar="IP", nargs="?", const="0.0.0.0,::", help="Specify the IP address to listen on (default: 127.0.0.1). You can give a list of ip addresses by separating them with a comma like: 127.2.2.2,127.3.3.3 If --listen is provided without an argument, it defaults to 0.0.0.0,:: (listens on all ipv4 and ipv6)")
parser.add_argument("--port", type=int, default=8188, help="Set the listen port.")
parser.add_argument("--port", type=int, default=8188, help="Set the listen port. Use 0 for a random available port (useful for desktop apps).")
parser.add_argument("--tls-keyfile", type=str, help="Path to TLS (SSL) key file. Enables TLS, makes app accessible at https://... requires --tls-certfile to function")
parser.add_argument("--tls-certfile", type=str, help="Path to TLS (SSL) certificate file. Enables TLS, makes app accessible at https://... requires --tls-keyfile to function")
parser.add_argument("--enable-cors-header", type=str, default=None, metavar="ORIGIN", nargs="?", const="*", help="Enable CORS (Cross-Origin Resource Sharing) with optional origin or allow all with default '*'.")
@ -239,6 +241,13 @@ else:
if args.windows_standalone_build:
args.auto_launch = True
if args.port != 0:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.bind(('', args.port))
sock.close()
except OSError:
args.port = 0
if args.disable_auto_launch:
args.auto_launch = False

View File

@ -1 +1 @@
comfyui_manager==4.0.4
comfyui_manager==4.0.5

View File

@ -1182,6 +1182,11 @@ class PromptServer():
port = addr[1]
site = web.TCPSite(runner, address, port, ssl_context=ssl_ctx)
await site.start()
if port == 0 and site._server and site._server.sockets:
port = site._server.sockets[0].getsockname()[1]
if verbose:
logging.info("Random port assigned: {}".format(port))
if not hasattr(self, 'address'):
self.address = address #TODO: remove this

View File

@ -160,3 +160,28 @@ def test_base_path_change_clears_old(set_base_dir):
for name in ["controlnet", "diffusion_models", "text_encoders"]:
assert len(folder_paths.get_folder_paths(name)) == 2
def test_windows_standalone_random_port():
"""Test that --windows-standalone-build uses port 0 when port is in use"""
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 8188))
try:
with patch.object(sys, 'argv', ["main.py", "--windows-standalone-build"]):
reload(comfy.cli_args)
assert comfy.cli_args.args.port == 0
assert comfy.cli_args.args.windows_standalone_build
finally:
sock.close()
with patch.object(sys, 'argv', ["main.py", "--windows-standalone-build", "--port", "9999"]):
reload(comfy.cli_args)
assert comfy.cli_args.args.port == 9999 or comfy.cli_args.args.port == 0
assert comfy.cli_args.args.windows_standalone_build
with patch.object(sys, 'argv', ["main.py"]):
reload(comfy.cli_args)
assert comfy.cli_args.args.port == 8188
assert not comfy.cli_args.args.windows_standalone_build