Node-Red flows disappear after a few hours

Hi,
I’m using node-red but noticed that all of my flows disappear every few hours.
Is that a known issue or configuration thing?

Here’s my package.json:

{
  "name": "my-glitch-app",
  "version": "0.0.1",
  "description": "What am I about?",
  "main": "server.js",
  "scripts": {
    "start": "node-red"
  },
  "dependencies": {
    "express": "^4.16.1",
    "node-red": "^0.20.5"
  },
  "engines": {
    "node": "8.x"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}

The only error messages I see in the log (when it starts after a change) are:

  • Your flow credentials file is encrypted using a system-generated key.

and

  • 29 May 11:59:58 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
    29 May 11:59:58 - [info] Server now running at http://127.0.0.1:3000/

Flows that I have created are all “deployed” before stopping.

Where are you storing node-red flows stored? The filesystem is persistent so if they’re files or data in a database within the /app directory then they shouldn’t get removed. It looks like node-red stores files outside of the /app directory by default. Try using --userDir and specifying a path within /app so they’re persisted correctly.

29 May 11:59:58 - [info] Settings file : /app/.node-red/settings.js
29 May 11:59:58 - [info] Context store : ‘default’ [module=memory]
29 May 11:59:58 - [info] User directory : /app/.node-red

This is what I see in the log… Would the “Context Store” have something to do with my issue? (“memory”?)

To be honest, in Glitch I don’t know where I can store node-red configuration changes

That’s it - it looks it’s storing data in memory, and so will be getting removed whenever the project sleeps. You can specify settings in the settings.js file which you can store in the user directory - from the above that looks like in /.node-red/settings.js

Ok, so it looks like the only question remaining is:
How can I update the settings.js file in the /app/.node-red/ folder?
I don’t know how to access this folder or if it’s possible to ‘append’ config items to the settings.js file via files in the Glitch ‘root folder’ that also contains the package.json and .env files.

Enjoying a great learning curve and thank you for your patience and support!

DJ

Hey @DJF3, I suspect that directory is hidden (due to the leading “.” in the folder name) so it won’t show up in your project’s file tree. You can still access the file from your project’s console and use a command line editor like nano or vim to edit the file.

If you care to share your project name someone could take a look to verify this is the case.

:slight_smile:

The console… Probably the only place I haven’t searched yet…

Thank you! Will let you know if this did the trick!

Strange enough the Node-red flows are gone after 1 day. In the log:

4 Jun 07:47:47 - [info] Settings file : /app/.node-red/settings.js
4 Jun 07:47:47 - [info] Context store : ‘default’ [module=localfilesystem]
4 Jun 07:47:47 - [info] User directory : /app/.node-red
4 Jun 07:47:47 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
4 Jun 07:47:47 - [info] Flows file : /app/.node-red/flows_ca28fb99fb34.json
4 Jun 07:47:47 - [info] Creating new flow file

The “Flows file” mentioned in the log: /app/.node-red/flows_ca28fb99fb34.json is actually the file that was supposed to be in Node-Red.
Just after that there’s a log entry “Creating new Flow file”.
Why would it do that and not load the Flows file that it mentions 1 line above?

The settings.json file in ~/app/.node-red/ folder has this configuration:

module.exports = {
// the tcp port that the Node-RED web server is listening on
uiPort: process.env.PORT || 1880,
contextStorage: {
    default: { module: "localfilesystem" }
},
etc...

after uncommenting “userDir” in settings.js and change it to "/app/.node-red/ it still failed.
It took 3 hours and my flow was gone. The log?

 4 Jun 13:56:17 - [info] User directory : /app/.node-red/
 4 Jun 13:56:17 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
 4 Jun 13:56:17 - [info] Flows file     : /app/.node-red/flows_b78c8506626c.json
 4 Jun 13:56:17 - [info] Creating new flow file
 4 Jun 13:56:17 - [warn] 
 ---------------------------------------------------------------------
 Your flow credentials file is encrypted using a system-generated key.

I’m a bit lost…

What turned out to solve the problem:

  • Edit ~/.node-red/settings.js
  • Uncomment: the line that starts with //flowFile
  • update to flowFile: 'yourflowname.json’

Now it uses 1 flow and loads that every time!