# Reload room config without restarting Node-RED After you edit `room-config.js` on the server (and save/upload it), you can have Node-RED reload it into `global.roomConfig` so all flows use the new config **without restarting Node-RED**. --- ## Option A: Auto-reload when you save the file (recommended) When `room-config.js` is saved on the server, it is reloaded automatically. No extra nodes to install—use the built-in **Watch** node. ### Add the “Config reload on save” flow Add these nodes and wire in order: | Order | Node type | Name | Config | |-------|-----------|------|--------| | 1 | **watch** (built-in) | Watch room-config | In the node config, enter the **file** to watch. One of: **`/root/.node-red/room-config.js`** (single file) or **`/root/.node-red`** (directory; then add the filter Function below so only `room-config.js` triggers reload). The Watch node puts the changed file path in `msg.payload` and `msg.filename`, and the short name in `msg.file`. | | 2 | **Exec** | Read room-config as JSON | **Command:** `node -e "console.log(JSON.stringify(require('/root/.node-red/room-config.js')))"` · **Append:** payload (so output becomes `msg.payload`). | | 3 | **Function** | Reload room config from payload | Paste the code from **[reload-room-config-function.js](reload-room-config-function.js)**. | **Wiring:** Watch → Exec → Reload room config from payload (Function). If you watch the **directory** `/root/.node-red` instead of the single file, insert a **Function** between Watch and Exec so only changes to `room-config.js` trigger a reload: ```javascript // Only pass through when the changed file is room-config.js if (msg.file !== 'room-config.js') return null; return msg; ``` After deploy, saving (or uploading) `/root/.node-red/room-config.js` will trigger the Watch → Exec → reload. Config updates with no restart and no manual reload. --- ## Option B: Manual reload (no file watcher) Use this if you prefer not to install the watch node. 1. **Inject** – e.g. “Reload config” (click to trigger). 2. **Exec** – same command as in Option A, step 3. 3. **Function** – same “Reload room config from payload” code as in Option A, step 4. **Wiring:** Inject → Exec → Function. Trigger the Inject after you upload a new `room-config.js`. --- ## Note `room-config.js` must export a plain object (no functions, no non-JSON values). The repo version is JSON-serializable.