Impossible to make nodered start automatically at boot

Hello
Itry to make nodered start at boot automatically.
As I use node.js 10.15.3, and so, nodered 0.20.5, I can not use PM2 to make nodered start automatically.
It seems that pm2 is not compatible with node.js 10.15.3

So, I followed an other way, using a file in init.d
The full description of what I did is here :slight_smile:

with this script, node-red starts at boot, but after a small minute, it crashes.
Attached you will find the log of node-red startup, maybe you can tell me why it crashes.

But when i start node-red manually, with a simple command in the terminal, it works fine, without crashing.

you will se in the log file that for tha last startup, wich was manual, everything is fine.
But in the before last start, node-red has been started by the init.d file, and after a while, it crashes.
Do you see something in this log file that can tell you why NR crashes?
node-red.log.txt (99.7 KB)

In what way?

You need to tell us what platform you are using.

If it is a Raspberry Pi for example, and indeed most modern versions of Linux, you should be using systemd.

Dave's script for the Pi will set all of that up for you.

You are ignoring the very obvious error that is shown repeatedly in that log file.

In fact, you don't need to be messing with startup files as Node-RED is clearly trying to start but is crashing repeatedly.

29 May 21:44:37 - [error] [http request:Load JPG image from axis] Error: connect EHOSTUNREACH 192.168.1.46:80
29 May 21:44:37 - [red] Uncaught Exception:
29 May 21:44:37 - Error: EACCES: permission denied, mkdir '//pki'
    at Object.mkdirSync (fs.js:752:3)
    at _verify_serverCertificate (/opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/node-opcua-client/src/client_base.js:339:12)
    at /opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/node-opcua-client/src/client_base.js:624:13
    at /opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/node-opcua-client/src/client_base.js:248:9
    at /opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/async/dist/async.js:3888:9
    at /opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/async/dist/async.js:473:16
    at replenish (/opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/async/dist/async.js:1006:25)
    at iterateeCallback (/opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/async/dist/async.js:995:17)
    at /opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/async/dist/async.js:969:16
    at Immediate.<anonymous> (/opt/plcnext/appshome/data/60002172000051/lib/node_modules/node-red-contrib-iiot-opcua/node_modules/async/dist/async.js:3885:13)

Shows you quite clearly that a node is crashing Node-RED because it doesn't have access to a file that it wants.

In reality no node should do that as all file access should be wrapped such that errors are returned.

The problem lies with the node node-red-contrib-iiot-opcua. You should raise an issue on GitHub for that node.

I believe we have seen multiple issues with that node and it does seem to be causing issues. (apologies if I've confused it with something else).

Hello
No this is not a rasp PI.
It’s a PLC based on Linux on WICH it is possible to install any other thing based on Linux
In the past the node.js version was something like 8.... now it is the new version that can be installed by default. But with the old version, NR could be started by PL2. Now the application diesn’t Start anymore.
This is the reason why I wanted to find an other way.
SystèmD is also not installed on my PLC.so Ican not use it . I tried to install it but unsuccessfully. If you have a good way to make it install correctly, tell me please,
Thanks for your help

Hello
After a while the errors related to the OPCUA IIOT DISAPPEAR, maybe just the time the device starts.

What's this PLC make and model (I'm curious)?
Perhaps search for the PLC make and model + start on boot. perhaps check see if they have forum you could ask on?

Well, it seems to be using the older init.d which is similar but you will need to look up the correct syntax to get Node-RED to run on startup. Make sure you use the right user id to start Node-RED and don't assume that the environment variables are set so you may not have a PATH for example.

Also, don't forget that Node-RED probably needs at least the network to already be started. If you have any database nodes like MongoDB or MySQL, they will also need to be active before Node-RED starts as would the Mosquitto MQTT broker.

You are clearly getting a network error for example where 192.168.1.46:80 is unreachable..