Global get, set problem

Hello there
I went through all the topics related to my problem, but unofrtunatelly i could not find the answer. I was looking for a solution, that allows me to save data that will survive restarts. So i have found that i need to change settings.js, and then use the localfilesystem storage for that purpose. So i have changed my settings,

contextStorage: {
default: {
module: "memory"
},
file: {
module: "localfilesystem"
}
},

after that i restarted nodered. Next i used global.set("sheetevents", "file"), to store my data. After restart, i tried to read data by

global.get("sheetevents") and by global.get("sheetevents","file") too. Neither of them worked.

Strangely, in sidebar's ContextData i could find the sheetevents variable, stored as it was intended, but still no luck to use it in a function. Anyone any help please?

LITTLE UPDATE, in side context bar it also dissapiered after a refreshed the sidebar..

Now after another restart i am getting a warning

"Unknown context store 'file' specified. Using default store."

What am i missing?

Have you modified the correct settings file, the location of the settings file is shown in the console at start up.
If the correct file, show us the edited section, including a few lines before and after.
Does the sidebar context show file as the context store for sheetevent

I hope i modified the correct one. Are there more settings files? I have found that in my user/nodered directory..The side bar doesnt show sheetevent after i refreshed it, so the problem originate probably from saving the value. The warning also inidicates, that nodered could not find the "file" storage,so he uses the default.

Your settings for context storage are like this

while my settings.js has this, which works:

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

Perhaps try changing your to match mine? "memoryOnly" and "memory" should both work.

ps If you use a change node to set a context variable, do you see the memory/file location dropdown?

image

Don't be distracted by the icon always being a hard disk stack, it's the text - in dove grey on white, teeniest of fonts - that counts!

Hello
Thanks for your suggestions, i will try to change the setting file.

This is what i see in change node

Look at the node-red startup log to see which settings file it is using.

It is the correct one. But i think the problem is with the fact, that nodered is running as service. So it is messing up things, and not using my settings file. I tried evey possible restart, no help.

I don't use Node-red on Windows but I suspect the problem with this in C:\Users<username>.node-red\settings.js

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

... is that the default is memoryOnly so every time you want to refer to a filesystem context variable you must remember to select "file".

Or I suppose in your first flow tab you could copy your variables from filesystem to memory.

Hello guys
Thanks for all of your helps
We found the reason, and i am gonna share it with thouse running in my shoes
The problem originates from Nodered beeing set up as a service...
So in case it is running as a service, the settings file is not the same as it should be. It is cloning somehow the settings.js, and i was not able to find it. So we destroyed the process, and started using nodered regularly, and now i am able to use different storages.
Thanks for every single effort to help me

I think you can declare the user directory in the service (at least if you are using NSSM as your service manager) in the arguments section with -u

I run 8 instances of NR as service in the same machine with different settings file.

Not a great idea to do this. Windows pipe locks the log file and it can never be rotated or delated and will eventually fill to a huge size.

Better to use the nssm built in logging options.

Ignore the values on these random screenshots I borrowed from the internet - they are here only to show options avaiable

1 Like

good to know, but i have a scheduled task, with which i restart node red every week, and i dont have trouble with file size currently, but there is a scope for improvement sure.