Files and watching¶
For commands to try first, see Watch files. This page describes selection, reading, limits, and source-specific behaviour.
Directory selection¶
Give the same command a directory to create a view for each supported file:
Files directly in docs/ appear in the docs section. Subfolders become sections:
reference/setup.md appears under reference, and reference/api/v1.md under
reference/api. Sections remain a flat list; the slash shows the folder context.
View labels are filenames, including their extensions.
Discovery runs once at startup. Selected files keep updating, including when they are replaced or recreated. Restart the command to discover newly added files. There is no recurring directory scan.
By default, discovery includes two subfolder levels and allows up to 32 views:
plotsrv watch docs/ --max-depth 0 # Root files only
plotsrv watch docs/ --include '*.md' # Markdown at every included depth
plotsrv watch docs/ --include 'reference/*.md' # Match a relative path
plotsrv watch docs/ --max-depth 3 --max-views 64
plotsrv watch docs/ --section Reports # Reports, Reports/reference, etc.
Quote patterns so your shell does not expand them. Repeat --include to match
any of several patterns. A pattern without / matches filenames; a pattern with
/ matches the complete relative path (* can span folders).
Supported formats are Markdown, HTML, CSV, JSON, YAML, TOML, INI/CFG,
the supported image formats, and .txt, .text, and .log files.
Code files (.py, .pyi, .r, .sql, .sh, .bash, .zsh, .js, .ts,
.css, .c, .h, .cpp, .go, .rs) open in the Code renderer with bounded
syntax highlighting, copy, wrapping and line-number controls. Extensions are
case-insensitive, so .R works too. Code is displayed, never executed. The view
selector shows a code icon with a language badge, such as PY, R or SQL. Existing
Python artifacts and snapshots remain supported. Specialised formats such as
HTML, Markdown, CSV and JSON keep their existing renderers.
Hidden files and folders, symlinks, special files, and unknown extensions are skipped. An include pattern narrows these formats; it does not enable arbitrary files.
Depth is configurable from 0 to 16, and the view limit from 1 to 64. Discovery
also stops after 10,000 directory entries, including skipped entries. Exceeding
either the entry or view limit stops startup with an explanation; plotsrv does
not silently choose a partial collection. Choose a narrower directory, lower the
depth, or filter the files. An unreadable directory or ambiguous duplicate view
identity also stops startup. If a root file and a file in a same-named subfolder
collide, --section Reports gives the whole collection an unambiguous prefix.
These are ordinary watches: existing head/tail, byte limits, materialisation,
and config settings apply to each file. Local preparation runs sequentially in
one watch worker, without a queue of file contents. Memory-backed documents
still occupy memory individually; use fewer views or the existing
--materialization file option when that matters. --label and --view-id apply
only to single-file commands; directory-only options require a directory.
Remote watching uses the same discovery and the existing bounded publisher:
All files are read on the machine running this command. The receiver needs no
shared filesystem, and remote transfer limits still apply. A configured publisher
destination also works; an explicit local --host or --port retains its existing
local-launch behaviour. No config files are generated by directory discovery.
Choose head or tail mode¶
Head mode reads from the start of the file.
Tail mode reads from the end of the file.
plotsrv also chooses sensible defaults based on the file type.
Limit large files¶
Large watched files can be limited in megabytes with --max-mb.
For local watches, the default is 500 MiB (500 × 1,048,576 bytes), as in
v0.5.0. This is a cap on bytes read for a preview, not a maximum file size:
larger text and CSV files can still provide a bounded head or tail preview.
Display limits may shorten the result further.
To read the full file:
--max-bytes is still available as a legacy/advanced option when byte-level precision is needed:
For large logs, keeping a read limit is usually better. It keeps the UI responsive and avoids reading too much from disk.
The equivalent config key is:
Remote watches selected with --destination or a configured publisher
destination use a separate transport. Each capture reads at most 256 KiB,
even when --max-mb is higher or off; larger text and CSV files provide
bounded previews. This fixed cap limits the bytes sent to the receiver.
Complete formats such as images must fit the remote capture bound. See
remote watched-file limits.
Watched CSV files also use table preparation limits:
Memory-backed and file-backed watched files¶
Watched files can be represented in two ways.
| Mode | Meaning | Best for |
|---|---|---|
memory |
plotsrv reads the watched file content and publishes a normal in-memory view | small files, simple local workflows |
file |
plotsrv keeps file metadata in memory and reads bounded previews from disk only when the browser asks for them | large logs, large CSV files, long-running servers |
auto |
plotsrv chooses based on file size and config | most workflows |
The default is auto.
Memory-backed watched files also pass through the hard
limits.published_objects checks. The default text artifact limit is 6,000,000
characters; an explicit lower value in your config can reject a watched HTML,
Markdown, or text file even when the read and truncation limits allow it.
In auto mode, small watched files behave like normal published objects. Larger files become file-backed views, so plotsrv does not keep the full file content in server memory.
The configured automatic threshold is 10 MiB by default. It was 20 MiB in
v0.5.0; later performance tuning moved it earlier to reduce memory held by
local watches. Automatic mode switches no later than the 8 MiB publish request
cap, avoiding a gap where a file could be read but not sent. This does not
lower the 500 MiB preview read cap. File-backed views load previews on demand
and can briefly return a busy response when
their concurrent load slots are occupied.
Force file-backed mode:
Force memory-backed mode:
For files attached to plotsrv run:
The equivalent config is:
Use file for large watched files when you want predictable memory use.
File-backed behaviour¶
File-backed watched files are designed to protect the plotsrv server from large in-memory payloads.
For file-backed text, markdown, HTML, JSON-like, and log files:
- the view is registered immediately
- plotsrv stores metadata such as path, file type, size, and read mode
/artifactreads a bounded preview from disk when the browser requests it- preview errors are shown in the UI as
watch_errormessages
For file-backed CSV files:
- the view appears as a table
/table/dataincrementally parses only the configured table rows and columns when the browser requests it- the server does not keep the raw CSV window or a full-file row count in memory
- the UI reports loaded rows and says when the full row count is unknown, rather than scanning the full file just to display a total
- export downloads the original live CSV source
The current source is streamed only from registered watched-file metadata, so a browser never supplies a filesystem path. Historical snapshots remain snapshot-based; they never fall through to the current source file.
Concurrent file-backed requests¶
File-backed previews use the same table limits as memory-backed tables. To prevent several browser clients materialising a large preview at once, plotsrv also bounds active disk loads:
The default allows two active loads. A short-lived busy response is retried by
the browser; it is visible rather than silently building an unbounded queue.
This setting controls concurrency only. limits.truncate_after.table_rows and
limits.truncate_after.table_columns remain the controls for the data shown.
If you explicitly set either table truncation limit to off, plotsrv honours
that choice, but a file-backed request may then need to retain a very large
table before it can return it to the browser.
If a file-backed watched file cannot be read, plotsrv shows a visible error view instead of hiding the failure behind a server error.
File types¶
plotsrv infers common file types from the extension.
| File type | Rendered as |
|---|---|
.log, .txt, unknown text |
Text |
.csv |
Table |
.json |
JSON |
.yaml, .yml |
JSON-like structured view |
.toml |
JSON-like structured view |
.ini, .cfg |
JSON-like structured view |
.md, .markdown |
Markdown |
.html, .htm |
HTML |
.png, .jpg, .jpeg, .gif, .webp, .bmp, .svg |
Image |
Freshness and storage defaults for watched files¶
Watched files are source-aware.
Global freshness settings do not mark watched-file views stale by default. A watched file might be static for a long time and still be valid.
To apply freshness to a watched file, opt that specific view in:
freshness-settings:
enabled: true
views:
"files:job log":
enabled: true
expected_every: 5m
warn_after: 10m
overdue_after: 30m
Storage is source-aware too.
Memory-backed watched-file publishes can be snapshotted only if watched storage is enabled with storage-settings.watch_enabled or a per-view watch_enabled override.
File-backed watched files are not stored as latest-state payloads or historical snapshots. Their data already lives on disk and is previewed from the source file.
Local delivery and idle resource use¶
Local watches retry temporary publication failures automatically, including startup congestion and server unavailability. Retries use capped backoff (up to 30 seconds) and publish the latest file contents, without queuing previous versions. A successful error notice does not count as delivery of the source content.
Only one local watch prepares and uploads at a time. Connection negotiation and cooldown checks happen before reading or parsing. After successful delivery, an unchanged memory-backed watch only checks file metadata once per second: it does not reread, parse or republish the file. File-backed watches retain lazy previews. Stopping the server interrupts local polling and retry waits; an already-running OS read or HTTP operation can finish within its existing limits.