Run node-red inside docker using pm2 & upgrade custom nodes

Run node-red inside docker using pm2 & upgrade custom nodes

So I am successfully running node red inside docker. Everything works fine until I try to upgrade a node previously installed using the palette. After installing the newer version, node red says "Node-RED must be restarted to enable upgraded modules".

My container is ephemeral and I do not intend to mount a volume onto it (think AWS Fargate).

So I decide to use pm2-runtime to run node red inside a docker container. To restart the node-red process without restarting the container, I expose a REST API to restart the pm2 process like this:

app.get("/_restart", (req, res) => {
    pm2.connect(function (err) {
        if (err) {
            ....
        } else {
            res.send("restarting...")
            pm2.restart('xxx', (err, app) =>{......})
....
....
}

When I run this new docker container,

  • node-red run successfully
  • I upgrade the custom node successfully, albeit with the msg "Node-RED must be restarted to enable upgraded modules"
  • I call "/_restart" REST API, and pm2 restarts the node-red process successfully
  • However, when I visit node-red in the browser the custom node is still at the previous version and is asking me to upgrade !! All flows are intact as they were.

Q. What happened there? Why didn't process restart work as node-red was expecting?

@knolleary @Paul-Reed Can you provide some thoughts on what might be wrong, or what must I do next to troubleshoot?

Can you confirm that NR has actually restarted - not spawned another instance ?

Can you view the log files from within the container ?

Can you try and do the NR restart from outside the container and see if that has the same result ?

Craig

The NR is actually restarted - The following image shows 3 different processes after each restart is triggered via pm2.

  • What log file must I check and what should I be looking for?
  • How can I restart NR outside of the container?

You will have to show us your startup code for the docker container and/or the YAML you built it with so we can tell you where to find the files etc

Craig

Running pm2 logs should show you the logs.

I wanted to know what logs you are after - NR logs I understand now.

Here you go:

First time the docker container is run:

After hitting /_restart API that restarts the process:

I cant see anything suspicious

No it looks OK - have you confirmed it is not an issue with the custom node you are trying to upgrade ?

What node is it ?

Craig

That's an interesting comment.

Some more info the custom node:

  • its a custom built node that is a pass-through "does nothing" "what comes in goes out" "no login"
  • the custom node sits in a git repo. and the catalog.json makes use of the git+https://.....#tag URL as pkg_url (since its available with NR-v1.0.1)
  • when I install the node the first time, it was at 1.0.3 and is successfully installed. Then I simple create a new git tag v1.0.4 and update the # tag in the pkg_url of catalog.json (remember - git+https://.....#tag)

So the node is still valid in that sense - there are no issues unless you mean something more when you says "issue with the custom node"

Can you try and update another node - to try and see if it is something with how your node is published rather than a generic issue with updating the docker container ?

Craig

Same issue with another node.

I am going to do the following next:

  • After upgrading the node via NR console, I will see it is making any changes to the underlying file system i.e. are the new files (specifically package.json) is stored on the filesystem or not.

Any other ideas?

So I finally got it.

The issue was with how I was updating the node. In the git repo. of my node, I was making a new commit and tagging a new version without bumping the version inside the package.json.
This was causing an issues because even after installing the 'new version' from NR editor, the pacakge.json of the node was showing the older version on the file system. Upon restarting NR, it reads the package.json and sees an old version and says "upgrade available".

Special thanks to @craigcurtin for following this through!

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