Newbie question - load initial flow and also in UI too

Ref Karlos and Nick O'leary from his youtube post (told me post it here). I'm a newby plz plz be gentle :slight_smile: I have my linux file system with nodejs v15 running. Node-red starts, visualizer runs and i can open up json files, deploy and run and all works fine. I've tried so many things.

My file system is structured this way
userDir:"/data/app/home/nol/.nodered",
nodesDir:"/data/app/.nodered/nodes",
core.json is deployed in the test userDir and nodesDir at this moment.

The problem is the core.json which is flowFile never starts on the server, so when i do myserver/red/api/ping it comes back as error in the page, when i manually load the core.json (import) and deploy the ping works.

So the default script isn't starting and I've hunted for reasons why. Also the script isn't loaded in the UI either

So my quesitons are:-

  1. How do i get the core.json (in settings config) to load by default (as server starts)
  2. How do i get the UI to autoload the default script or what approach do i need to take to achieve this

Any pointer or references I am so grateful (banging my head here). I am new generally to this, and if I've done something silly, please do not shout hehe :slight_smile:

Thanks to everyone here

Karlos

The settings config is in the nodejs script

var settings = {
  httpAdminRoot:"/red",
  httpNodeRoot: "/api",
  userDir:"/data/app/home/nol/.nodered/",
  nodesDir:"/data/app/.nodered/nodes",
  flowFile:"core.json",
  logging:{   console: {
        level: "trace",
        metrics: false,
        audit: false
    }
  },
  functionGlobalContext: { },    // enables global context
  editorTheme: {
      header: {
          title: "Node RED",
          image: "/data/app/files/images/custom.gif", // or null to remove image
          url: "myurl" // optional url to make the header text/image a link to this url
      },
      projects: {
         enabled: false
      },
      page: {
          title: "Node RED visualizer",
          scripts: ["/data/app/.nodered/core.json"]
      }
  }
};

The NodeJS is

  RED.init(server,settings);

  // Serve the editor UI from /red
  app.use(settings.httpAdminRoot,RED.httpAdmin);
  app.use(settings.httpNodeRoot,RED.httpNode);
 RED.start().then((result) => {
    console.log("Event : Node Red has started successfully");
});

Is there a reason you are using your own node.js code to run Node-RED, rather than run it directly using the node-red command?

When Node-RED starts up it logs the full path to the flows files it is using. Given the configuration you have, what does it log?

userDir:"/data/app/home/nol/.nodered/",
  nodesDir:"/data/app/.nodered/nodes",

Why are you using /home/nol/ in the path? That appears in the default settings file as an example path (its actually the home directory on my laptop - nol is my username).

I've integrated into the nodejs script which i read was an option, I was considering running it from the command line with a separate settings file but yet to do that.

as for the home/no1, i was simply replicating an example i saw but this will change later, but paths physically exist on the server.

also even with Node-red integrated in the nodejs script this is the log output

Dec 00:37:35 - [info] Loading palette nodes
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-actionflows 2.0.3
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-actionflows
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-browser-utils 0.0.9
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-browser-utils
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-file-buffer 0.0.3
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-file-buffer
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-image-output 0.6.3
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-image-output
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-mic 0.0.1
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-mic
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-pdf 0.1.0
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-pdf
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-play-audio 2.5.0
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-play-audio
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-socketio 1.0.7
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-socketio
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-contrib-zip 1.0.0
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-contrib-zip
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-dashboard 2.24.2
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-dashboard
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-alexa 1.0.13
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-alexa
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-aws 0.1.8
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-aws
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-google 0.2.2
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-google
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-rbe 0.2.9
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-rbe
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-tail 0.1.1
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-tail
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-ui-table 0.3.10
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-ui-table
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] Module: node-red-node-watson 0.9.2
2020-12-05 00:37:35 b92cec5d61eb 5 Dec 00:37:35 - [debug] /data/app/node_modules/node-red-node-watson
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [warn] [RED.events] Deprecated use of "nodes-started" event from "/data/app/node_modules/node-red-contrib-actionflows/actionflows/actionflows.js:615:14". Use "flows:started" instead.
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] Dashboard version 2.24.2 started at /api/ui
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] utils.writeFile - copied /data/app/home/nol/.nodered/.config.nodes.json TO /data/app/home/nol/.nodered/.config.nodes.json.backup
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] utils.writeFile - written content to /data/app/home/nol/.nodered/.config.nodes.json.$$$
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] utils.writeFile - renamed /data/app/home/nol/.nodered/.config.nodes.json.$$$ to /data/app/home/nol/.nodered/.config.nodes.json
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] Context store : 'default' [module=memory]
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] User directory : /data/app/home/nol/.nodered
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [warn] Projects disabled : editorTheme.projects.enabled=false
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] Flows file : /data/app/home/nol/.nodered/core.json
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] Creating new flow file
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [debug] loaded flow revision: d751713988987e9331980363e24189ce
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [debug] red/runtime/nodes/credentials.load : no user key present
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [debug] red/runtime/nodes/credentials.load : no default key present - generating one
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [debug] red/runtime/nodes/credentials.load : keyType=system
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [warn]

2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] utils.writeFile - copied /data/app/home/nol/.nodered/.config.runtime.json TO /data/app/home/nol/.nodered/.config.runtime.json.backup
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] utils.writeFile - written content to /data/app/home/nol/.nodered/.config.runtime.json.$$$
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] utils.writeFile - renamed /data/app/home/nol/.nodered/.config.runtime.json.$$$ to /data/app/home/nol/.nodered/.config.runtime.json
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] runtime event: {"id":"runtime-state","retain":true}
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"d751713988987e9331980363e24189ce"},"retain":true}
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] Starting flows
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [debug] red/nodes/flows.start : starting flow : global
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] [flow:global] start flow [global]
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [trace] runtime event: {"id":"runtime-state","retain":true}
2020-12-05 00:37:36 b92cec5d61eb 5 Dec 00:37:36 - [info] Started flows

The log output contains this:

[info] Flows file : /data/app/home/nol/.nodered/core.json
[info] Creating new flow file

This tells you exactly what path it is using for the flow file - and that it has not found an existing file there, so is creating a new file.

So /data/app/home/nol/.nodered/core.json does not exist. If you copy your flow file to that exact location, then Node-RED will load it.

Maybe i'm missing something but that's exactly what I have, virtually the path starts at /data/app. The image is what i see in FTP.

You have created a directory called no1 but the configuration uses nol.

ahhhhhhhhh well spotted, let me retry, cannot tell the characters apart, so would never have spotted that.

Right Mister, I am in your debt! I need a new pair of glasses in my 40's, and its all working. So I want to thank you kindly for taking pity on a newby, the scripts load and run and the UI loads up the script.

What an amazing platform, and a real credit to the work you and everyone else has put in.

I will watch more of your tutorials and updates. Again thank you so so much! I can now cross this off my to-do list!

Thank you kindly

Karlos

1 Like

There are certain co-exist conditions on small scale services that allow for the data to potentially be shared between the two. I assume running this in its own nodejs start up process gives more bandwidth resources? What I might do is create a separate settings js file and try running the node-red as a separate option. I'm happy to follow your advice on any pros cons. I've changed the directory structure now as i was just following basic example of a settings example that was posted. I've changed that now.

Cheers

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