Anton Bakulin

Hot Reload

Contents

OnyxFolio watches your vault for file changes and reloads automatically on the next request. There is no file watcher process — the check happens in the request path.


How it works

On every incoming request, maybe_reload() runs:

  1. Checks the newest file modification time across all vault files.
  2. Compares it against the last known scan time.
  3. If anything changed, re-runs the full load_posts() pipeline and swaps in the new data.

A 2-second debounce prevents multiple simultaneous reloads — if a request arrives within 2 seconds of the last check, the check is skipped.


What triggers a reload

Any change to any file in the vault directory:


Thread safety

Reloads are protected by a threading.Lock. If two requests arrive simultaneously and both detect a change, only one performs the reload — the other skips it and serves the previous (stale-by-milliseconds) data.


Development workflow

  1. Start the server: python3 app.py
  2. Edit notes in Obsidian (or any editor)
  3. Save and refresh the browser — the change is live

No --watch flags. No separate process. No restart.


Production note

Hot reload also works in production. When you push a vault update and Coolify rebuilds the Docker image, the new vault is loaded at startup. If you're running a long-lived process (gunicorn) with the vault mounted as a volume, changes are picked up automatically on the next request.


See also