mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-27 01:17:24 +08:00
feat: early port availability check before custom node loading (#13096)
Move port check to the start of main.py (before custom node
initialization) so users get immediate feedback if the port is
already in use, instead of waiting through slow custom node loading.
- Uses socket.connect_ex() on 127.0.0.1:{port}
- Prints clear error message and exits with code 1 if port taken
- +12 lines, no new dependencies
This commit is contained in:
parent
a694c3b58f
commit
17e315f6e9
12
main.py
12
main.py
@ -37,6 +37,18 @@ if __name__ == "__main__":
|
||||
os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1'
|
||||
os.environ['DO_NOT_TRACK'] = '1'
|
||||
|
||||
# Early port availability check — fail fast before slow custom node loading
|
||||
import socket as _early_socket
|
||||
_port = getattr(args, 'port', 8188)
|
||||
try:
|
||||
with _early_socket.socket(_early_socket.AF_INET, _early_socket.SOCK_STREAM) as s:
|
||||
s.settimeout(1)
|
||||
if s.connect_ex(('127.0.0.1', _port)) == 0:
|
||||
print(f"ERROR: Port {_port} is already in use. Please free the port or specify a different one with --port.", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
faulthandler.enable(file=sys.stderr, all_threads=False)
|
||||
|
||||
import comfy_aimdo.control
|
||||
|
||||
Loading…
Reference in New Issue
Block a user