mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-22 01:23:43 +08:00
fix: gracefully handle port-in-use error on server startup
Catch EADDRINUSE OSError when binding the TCP site and exit with a clear error message instead of an unhandled traceback. Amp-Thread-ID: https://ampcode.com/threads/T-019cf85a-650a-73fa-8201-1dbddcbbd9e4 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
parent
b202f842af
commit
425ed43cc6
@ -1,3 +1,4 @@
|
|||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
@ -1236,7 +1237,13 @@ class PromptServer():
|
|||||||
address = addr[0]
|
address = addr[0]
|
||||||
port = addr[1]
|
port = addr[1]
|
||||||
site = web.TCPSite(runner, address, port, ssl_context=ssl_ctx)
|
site = web.TCPSite(runner, address, port, ssl_context=ssl_ctx)
|
||||||
await site.start()
|
try:
|
||||||
|
await site.start()
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno == errno.EADDRINUSE:
|
||||||
|
logging.error(f"Port {port} is already in use on address {address}. Please close the other application or use a different port with --port.")
|
||||||
|
raise SystemExit(1)
|
||||||
|
raise
|
||||||
|
|
||||||
if not hasattr(self, 'address'):
|
if not hasattr(self, 'address'):
|
||||||
self.address = address #TODO: remove this
|
self.address = address #TODO: remove this
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user