When attempting to store variables, they simply get lost upon reboot.
This is my settings.js:
module.exports = {
flowFile: 'flows.json',
flowFilePretty: true,
contextStorage: {
default: "memoryOnly",
memoryOnly: { module: 'memory' },
file: { module: 'localfilesystem' }
},
Startup Log:
26 Jul 10:13:23 - [info]
Welcome to Node-RED
===================
26 Jul 10:13:23 - [info] Node-RED version: v2.2.2
26 Jul 10:13:23 - [info] Node.js version: v14.18.2
26 Jul 10:13:23 - [info] Linux 4.15.0 x64 LE
26 Jul 10:13:24 - [info] Loading palette nodes
26 Jul 10:13:27 - [info] Dashboard version 3.1.6 started at /ui
26 Jul 10:13:28 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
26 Jul 10:13:28 - [info] Settings file : /data/settings.js
26 Jul 10:13:28 - [info] Context store : 'memoryOnly' [module=memory]
26 Jul 10:13:28 - [info] Context store : 'file' [module=localfilesystem]
26 Jul 10:13:28 - [info] User directory : /data
26 Jul 10:13:28 - [info] Projects directory: /data/projects
26 Jul 10:13:28 - [info] Server now running at https://127.0.0.1:1880/
26 Jul 10:13:28 - [info] Active project : Test2
26 Jul 10:13:28 - [info] Flows file : /data/projects/tests2/flows.json
26 Jul 10:13:28 - [info] Starting flows
26 Jul 10:13:28 - [info] Started flows
26 Jul 10:13:28 - [info] [mqtt-broker:randomID] Connected to broker: mqtt://my.secret.IP:1883
To test, I set the variable, restart nodered, then try to retrieve the value.
Set the value:
flow.set("ID", 123, "file");
msg.payload = flow.get("ID", "file");
return msg;
Retrieve the value:
var count = flow.get("ID", "file")||0;
msg.payload = count;
return msg;
Expected result:
After a restart, the msg.payload value should be "123".
Actual result:
After a restart, the msg.payload value is "0".
In addition, the change node doesn't give an option to select contextStorage, as if there's only one option available.
Does anyone have an idea, why this doesn't work.