Install the whole backend from one script; queue log; UI fixes

install_comfyui.sh becomes install_backend.sh and now builds everything the app
needs, not just the speech half:

- Step 7 runs normalizer/setup.sh --model, which fetches both models: the open
  inflection model first, so the install gets as far as it can before anything
  can ask for credentials, then the gated fine-tune.
- A missing Hugging Face account is no longer fatal. Accepting a licence is the
  one thing an installer cannot do, so the rest installs, the verification
  reports "fallback only (gated model missing)", and the summary prints the
  three commands that finish it.
- --skip-normalizer, disk requirement 35 -> 55 GB, removal instructions and the
  step list updated to match.

Queue logging — queue.log in the first queued video's job folder, which for a
single-video run is its own:

- Records what went wrong rather than what happened: warnings, tracebacks,
  ffmpeg errors, guard rejections, clips cut off mid-word or that crashed the
  backend, and the --regen line carrying their numbers.
- ComfyUI failures *and* restarts, so the log shows the recovery rather than
  reading as though the run simply stopped. GUI-initiated backend actions go in
  too; they never pass through a job's pipe.
- A failure also dumps the job's last 15 lines. Keyword matching alone is not
  enough — ffmpeg says "Invalid data found when processing input" and nothing
  that looks like an error.

UI:

- The output pane follows new output only while already at the bottom. Scroll up
  and it stays there; scroll back down and it resumes. Reading an earlier
  warning during a run was impossible while every ffmpeg progress frame yanked
  the view to the end.
- The ComfyUI button's status dot is drawn as its own canvas item, so it can be
  green (answering) or amber (holds the port, does not answer). A "." inside the
  label could only ever be the same grey as the words.

comfyui.log is capped at 120,000 lines, trimmed on backend start and every five
minutes. Rewritten in place, never replaced: tee holds it open in append mode,
so swapping the inode would leave the backend writing to an unlinked file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 09:48:20 +02:00
co-authored by Claude Opus 5
parent e201aadc3e
commit 97866e6623
8 changed files with 421 additions and 69 deletions
+35
View File
@@ -83,6 +83,12 @@ COMFY_AUTOSTART = True
COMFY_START_SCRIPT = Path(__file__).resolve().parent / "start_comfyui.sh"
COMFY_LOG = Path(__file__).resolve().parent / "comfyui.log"
# The backend log is appended to for ever otherwise — it reached 10 MB here in
# a couple of days. Trimmed to the newest lines rather than rotated, so there is
# one file to look at after a crash and no .1 .2 .3 to hunt through.
COMFY_LOG_MAX_LINES = 120_000
_LOG_TRIM_MIN_BYTES = 2 << 20 # below this it cannot plausibly be over the cap
def load_settings(path: Path) -> dict:
"""Read settings.ini, falling back to _DEFAULTS for anything missing.
@@ -1533,6 +1539,7 @@ def start_comfy_backend(script: Path) -> bool:
_autostart["attempts"] += 1
_autostart["last"] = now
trim_comfy_log() # before the backend opens it again
# Pause on exit so a backend that fails to start leaves its error on screen
# instead of the window vanishing.
log = COMFY_LOG
@@ -1567,6 +1574,34 @@ def start_comfy_backend(script: Path) -> bool:
return True
def trim_comfy_log(path: Path = None, max_lines: int = COMFY_LOG_MAX_LINES) -> int:
"""Drop the oldest lines of the backend log, keeping the newest `max_lines`.
Returns how many were dropped.
Rewritten in place rather than replaced. `tee` holds the file open in append
mode, so the inode must survive: writing a new file and renaming it over the
old one would leave tee appending to an unlinked inode, and every later line
would vanish silently. Rewriting in place works because O_APPEND directs
each write to the current end of file rather than to a remembered offset.
"""
path = path or COMFY_LOG
try:
if not path.is_file() or path.stat().st_size < _LOG_TRIM_MIN_BYTES:
return 0
data = path.read_bytes()
if data.count(b"\n") <= max_lines:
return 0
lines = data.splitlines(keepends=True)
dropped = len(lines) - max_lines
with path.open("r+b") as handle:
handle.write(b"".join(lines[-max_lines:]))
handle.truncate()
return dropped
except OSError as exc:
print(f" Could not trim {path.name}: {exc}", file=sys.stderr)
return 0
def wait_for_backend(timeout: float = 300.0) -> bool:
"""Block until the backend answers again. After a restart the port is not
listening for a while, and submitting into it would look like another