Best method or implementation for storage context between stop and start of node red?

Best method or implementation for storage context between stop and start of node red? Truth be told I have not dig into this as yet, which I usually research design goals before asking questions, but in this case, need a solution idea faster than usual, under a time crunch.

The initial thought was just to capture the context information to file, dynamically, as changes made... I don't have a lot of such data to retain. Then on node-red start up, load file content in. But maybe someone has something more elegant?

Maybe using the built-in File System based context store?

Did I miss something reviewing the documentation noted above, the context state, if you will, is flushed every 30 seconds? Is an explicit flush done at node-red shutdown? I did not see that mentioned in the documentation? That would be done, IMHO. But maybe not. Searched for discussion on flow execution at node red shutdown, not sure this exists as a feature.

Can the location of the context folder be on shared storage? I have two node red instances, but only one is active at a time, so would need to share context when secondary spins up on primary failure.

Yes the context is flushed on shutdown - it would be pretty useless if it didn't.

You can configure the file store to be on any path -

:slight_smile: Yeah, I could not imagine that not being done. But had to ask. Thanks for the suggestion, this looks like it will work just as I need.

Long before the file system based context store was available in NR, I did actually do something myself. I basically saved/updated a file with an object as content. The object had all variables that I wanted should survive a restart. It also held variables with static content (like some public holiday dates and other stuff). At NR start, I use this data and initiate all the variables

Next I experimentet putting all that retained into the MQTT broker. My broker was running on a separate system, it also worked ok but, if I remember correctly, I think I lost the data if I terminated both NR and the broker at the same time. So not so good

Now I'm actually back to my original solution but saving to a mounted usb stick to avoid eventual SD card problems

EDIT: I was wrong, I'm actually using the MQTT variant where the broker is running on a different RPi

In my case, I have a database I can use, I also have some shared storage I could use. However, I don't see the need for a lot of stops and starts, so I am not that worried about SD swear per se. I have some tinkering to do, before I decide how or what to use.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.