Browse Source

improve: logging supports multi port

pull/128/head
dr.lt.data 1 year ago
parent
commit
dee6cd8969
  1. 2
      __init__.py
  2. 22
      prestartup_script.py

2
__init__.py

@ -56,7 +56,7 @@ sys.path.append('../..')
from torchvision.datasets.utils import download_url
# ensure .js
print("### Loading: ComfyUI-Manager (V0.32)")
print("### Loading: ComfyUI-Manager (V0.33)")
comfy_ui_required_revision = 1240
comfy_ui_revision = "Unknown"

22
prestartup_script.py

@ -7,20 +7,28 @@ import threading
import re
try:
if '--port' in sys.argv:
port_index = sys.argv.index('--port')
if port_index + 1 < len(sys.argv):
port = int(sys.argv[port_index + 1])
postfix = f"_{port}"
else:
postfix = ""
# Logger setup
if os.path.exists("comfyui.log"):
if os.path.exists("comfyui.prev.log"):
if os.path.exists("comfyui.prev2.log"):
os.remove("comfyui.prev2.log")
os.rename("comfyui.prev.log", "comfyui.prev2.log")
os.rename("comfyui.log", "comfyui.prev.log")
if os.path.exists(f"comfyui{postfix}.log"):
if os.path.exists(f"comfyui{postfix}.prev.log"):
if os.path.exists(f"comfyui{postfix}.prev2.log"):
os.remove(f"comfyui{postfix}.prev2.log")
os.rename(f"comfyui{postfix}.prev.log", f"comfyui{postfix}.prev2.log")
os.rename(f"comfyui{postfix}.log", f"comfyui{postfix}.prev.log")
original_stdout = sys.stdout
original_stderr = sys.stderr
tqdm = r'\d+%.*\[(.*?)\]'
log_file = open("comfyui.log", "w", encoding="utf-8")
log_file = open(f"comfyui{postfix}.log", "w", encoding="utf-8")
log_lock = threading.Lock()
class Logger:

Loading…
Cancel
Save