- Use filelock (FileLock) instead of PRAGMA locking_mode=EXCLUSIVE to
prevent multi-process database access. The OS automatically releases
the lock when the process exits, even on crashes or Ctrl+C.
- Add friendly error messages for database-is-locked and general
database init failures when --enable-assets is set.
- Exit the process instead of silently disabling assets when the user
explicitly passed --enable-assets and the database fails.
- Add filelock to requirements.txt.
Amp-Thread-ID: https://ampcode.com/threads/T-019cbab8-50d4-748c-9669-2506575dda44
Co-authored-by: Amp <amp@ampcode.com>
The previous commit acquired the exclusive lock before Alembic migrations,
but Alembic opens its own connection — which was then blocked by our lock.
Move lock acquisition to after migrations complete in a dedicated connection.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When two ComfyUI processes share the same database file but point to
different input/output/model directories, each process's scan marks
the other's assets as missing, causing unreliable asset visibility.
This adds an exclusive lock so the second process fails fast at startup
with a clear message to use --database-url.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>