Context file not written when using multiple localfilesystem entries

I need to have seperate localfilesystems. I tried this config based on a forum example, yet noticed that when something is saved in "file" it also automatically gets saved in "file2" and "file3". I understand that there are base/dir parameters that can be added but can't figure out where/how. Thanks!


contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem' },
   file2: { module: 'localfilesystem' },
   file3: { module: 'localfilesystem' }
},

The docs you need are here: Working with context : Node-RED

In particular, the highlighted note:

Note : if you choose to configure multiple localfilesystem stores, you must set their dir option so they use different directories to store data. Details on how to configure the store is available here

So in that case, you could do something like this (just make sure to update the dir values to real paths you have).

contextStorage: {
   default: "memoryOnly",
   memoryOnly: { module: 'memory' },
   file: { module: 'localfilesystem', dir: '/home/user/.node-red/context1' },
   file2: { module: 'localfilesystem', dir: '/home/user/.node-red/context2' },
   file3: { module: 'localfilesystem', dir: '/home/user/.node-red/context3' }
},
1 Like

Hi, thanks!

Adding directories seemed to address the issue of data getting saved in their respective (specified) filesystems (without cross-saves) on the app side. However, oddly I cannot locate the new files in the specified directory, nor anywhere else in the drive (I searched).

Have you added anything to those context stores?

Can you show us what you did to set a value in the other context stores?

You can see some data in memory, some in default "file" (dir not specified in settings) and some in the "transact" file (which I can't locate)

flow.set('recordKeeper', check, 'transact');
flow.set('recordKeys', check, 'transact');

Does /home/ubuntu exist?
Does /home/ubuntu/node-red exist (note, no dot)

Yes, they exist

Please stop node red then start it again in a terminal, then write something to the context store and stop node red again. Copy/paste the full log here. I don't know if it will tell us anything, but it may do.

Where is the log file typically located?

How are you running node-red? Installed locally? Via snap install? In a container (docker/home assistant/etc)

AWS linux ubuntu

When you run the command
node-red
The log appears in the terminal.

That tells us nothing about how you installed node red.

Yes, I am aware of that. I was asking about location of the log file since I am not able to find it.

Thats why you were asked

So stop the node-red service and run (from it from a terminal as described) - you will see the node-red startup log and it will contain path details.

The commands that were suggested (in another post) to stop node-red service don't seem to be working in my case ...

Here is my directory structure with node-red install

Here is what I get when I run node-red (while it's running)

How did you install Node-RED originally? Was it using the install script we provide?

If so, then do you have the commands node-red-stop and node-red-start ? Those would be the right way to start/stop the service.

The log output you've shared may be misleading if you're running as a different user - because it will be using the current user's home directory for its settings file. Given it is only logging about one context store (the default one), then I suspect it isn't picking up the same settings file as the service is.

So, if you did use our install script, then please try using node-red-stop and node-red-start to restart the service. You should also have node-red-log that get the recent log output.

If you installed some other way, then please share any details you can so we can track down exactly where it is running.

Installed using these instructions (ubuntu running on ec2)

https://nodered.org/docs/getting-started/aws#running-on-aws-ec2-with-ubuntu

Here is what I get with "node-red stop" (under both root and ubuntu user)

Okay - so you installed and run it with pm2 - is that correct?

In which case you will not have the node-red-start and node-red-stop commands (note they are one-word, not node-red stop as you have tried running).

If you run pm2 list what do you see?

To get to the logs, you would use pm2 logs with the name of the application from pm2 list that you want to see the logs for