node-red-contrib-chokidar-watcher
v1.0.1
Published
Node-RED node to watch folders using chokidar with awaitWriteFinish support
Maintainers
Readme
node-red-contrib-chokidar-watcher
Node-RED node to watch folders using chokidar
with awaitWriteFinish support: events fire only after a file has finished
being written.
This solves the classic problem of the core watch node (and inotify-based
watchers) firing while a file is still being uploaded — e.g. sensors pushing
data files over FTP, where you must not process a file until the transfer
completes.
Install
From the Node-RED editor: Menu → Manage palette → Install and search for
node-red-contrib-chokidar-watcher, or from your Node-RED user directory
(typically ~/.node-red):
npm install node-red-contrib-chokidar-watcherUsage
Drop the chokidar-watcher node into a flow and configure the folder to watch. Every filesystem event emits a message:
{
"payload": {
"type": "file",
"event": "add",
"path": "/data/incoming/sensor_data.xml",
"filename": "sensor_data.xml"
}
}type:fileordirectoryevent: chokidar event (add,change,unlink,addDir,unlinkDir)path: full path of the affected filefilename: basename
Configuration
| Option | Default | Description |
|---|---|---|
| Folder | — | Path to watch (recursive) |
| Persistent | true | Keep the process alive while watching |
| Stability threshold (ms) | 2000 | File size must stay constant this long before the event fires (awaitWriteFinish.stabilityThreshold) |
| Polling interval (ms) | 100 | File size polling rate while waiting for stability (awaitWriteFinish.pollInterval) |
Initial scan events are ignored (ignoreInitial: true): only changes after
deploy are reported.
Notes
- On network filesystems (CIFS/NFS) events may not propagate for writes made from other hosts; writes made through the same mount (e.g. an FTP server in the same pod/container) work fine.
License
MIT
