I can't stop NR (I can only kill process)

Hi, on OrangePi zero I run NR by command node-red, in past it exited with a control^c, now it hangs and I don't know why. The cpu keeps minumum, but the ram won't get free, I need to kill the PID. Maybe a module?
immagine

Try setting the log level to trace in settings.js and see if you get more information.

Thank you for hep Colin, I did it but honestly I don't understand much, can't see where the problem could be. It hangs (

Welcome to Node-RED
===================

23 Apr 21:54:26 - [info] Node-RED version: v3.0.2
23 Apr 21:54:26 - [info] Node.js  version: v12.22.9
23 Apr 21:54:26 - [info] Linux 5.15.93-sunxi arm LE
23 Apr 21:54:32 - [info] Loading palette nodes
23 Apr 21:54:34 - [debug] Module: node-red-contrib-dev-input 0.0.1 /home/pi/.node-red/node_modules/.node-red-contrib-dev-input-master-wkEQH2Qr
23 Apr 21:54:34 - [debug] Module: node-red-contrib-buffer-parser 3.2.2 /home/pi/.node-red/node_modules/node-red-contrib-buffer-parser
23 Apr 21:54:34 - [debug] Module: node-red-contrib-moment 4.0.0 /home/pi/.node-red/node_modules/node-red-contrib-moment
23 Apr 21:54:34 - [debug] Module: node-red-contrib-play-audio 2.5.0 /home/pi/.node-red/node_modules/node-red-contrib-play-audio
23 Apr 21:54:34 - [debug] Module: node-red-contrib-telegrambot 15.0.1 /home/pi/.node-red/node_modules/node-red-contrib-telegrambot
23 Apr 21:54:34 - [debug] Module: node-red-node-pi-gpio 2.0.6 /home/pi/.node-red/node_modules/node-red-node-pi-gpio
23 Apr 21:54:34 - [debug] Module: node-red-node-ping 0.3.3 /home/pi/.node-red/node_modules/node-red-node-ping
23 Apr 21:54:34 - [debug] Module: node-red-node-random 0.4.1 /home/pi/.node-red/node_modules/node-red-node-random
23 Apr 21:54:34 - [debug] Module: node-red-node-serialport 1.0.3 /home/pi/.node-red/node_modules/node-red-node-serialport
23 Apr 21:54:34 - [debug] Module: node-red-node-smooth 0.1.2 /home/pi/.node-red/node_modules/node-red-node-smooth
23 Apr 21:54:47 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
23 Apr 21:54:47 - [info] Settings file  : /home/pi/.node-red/settings.js
23 Apr 21:54:47 - [info] Context store  : 'default' [module=memory]
23 Apr 21:54:47 - [info] User directory : /home/pi/.node-red
23 Apr 21:54:47 - [warn] Projects disabled : editorTheme.projects.enabled=false
23 Apr 21:54:47 - [info] Flows file     : /home/pi/.node-red/flows.json
23 Apr 21:54:47 - [debug] loaded flow revision: 60b94ea3730f4d3c9db95098d4db2665
23 Apr 21:54:47 - [debug] red/runtime/nodes/credentials.load : no user key present
23 Apr 21:54:47 - [debug] red/runtime/nodes/credentials.load : using default key
23 Apr 21:54:47 - [debug] red/runtime/nodes/credentials.load : keyType=system
23 Apr 21:54:47 - [warn]

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

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

23 Apr 21:54:47 - [trace] runtime event: {"id":"runtime-state","retain":true}
23 Apr 21:54:47 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"60b94ea3730f4d3c9db95098d4db2665"},"retain":true}
23 Apr 21:54:47 - [info] Server now running at http://127.0.0.1:1880/
23 Apr 21:54:47 - [info] Starting flows
23 Apr 21:54:47 - [debug] red/nodes/flows.start : starting flow : global
23 Apr 21:54:47 - [debug] red/nodes/flows.start : starting flow : 626d1e142ebe1eeb
23 Apr 21:54:47 - [trace] [flow:global] start flow [global]
23 Apr 21:54:47 - [trace] [flow:global] ------------------|--------------|-----------------
23 Apr 21:54:47 - [trace] [flow:global]  id               | type         | alias
23 Apr 21:54:47 - [trace] [flow:global] ------------------|--------------|-----------------
23 Apr 21:54:47 - [trace] [flow:global]  ad7ab8444019846b | telegram bot |
23 Apr 21:54:47 - [trace] [flow:global] ------------------|--------------|-----------------
23 Apr 21:54:47 - [trace] [flow:626d1e142ebe1eeb] start flow [626d1e142ebe1eeb]
23 Apr 21:54:47 - [debug] [inject:3b9da984b6bd127f] crontab = 00 12 * * *
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb] ------------------|--------------|-----------------
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  id               | type         | alias
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb] ------------------|--------------|-----------------
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  fc436b5f4496cac8 | telegram sender |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  3b9da984b6bd127f | inject       |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  e5bd371694541cdd | function     |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  ef4078259a03ca02 | telegram receiver |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  18297c3afe9f7448 | debug        |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  60d4f05299231f3d | function     |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  dee634b0eb19fd96 | moment       |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  30f94d14759c1b55 | dev-input    |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  f88972758820db18 | function     |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb]  93eea5bca44ae1d5 | trigger      |
23 Apr 21:54:48 - [trace] [flow:626d1e142ebe1eeb] ------------------|--------------|-----------------
23 Apr 21:54:48 - [trace] runtime event: {"id":"runtime-state","payload":{"state":"start"},"retain":true}
23 Apr 21:54:48 - [info] Started flows
23 Apr 21:55:01 - [trace] comms.open v0PG8FECUxnh6Mq5JDWWL2ZWS0SHT95Iz9qLUD3dx/s=
^C23 Apr 21:55:07 - [info] Stopping flows
23 Apr 21:55:07 - [debug] red/nodes/flows.stop : stopping flow : 626d1e142ebe1eeb
23 Apr 21:55:07 - [trace] [flow:626d1e142ebe1eeb] stop flow
23 Apr 21:55:07 - [trace] Stopping node telegram sender:fc436b5f4496cac8
23 Apr 21:55:07 - [trace] Stopping node inject:3b9da984b6bd127f
23 Apr 21:55:07 - [trace] Stopping node function:e5bd371694541cdd
23 Apr 21:55:07 - [trace] Stopping node telegram receiver:ef4078259a03ca02
23 Apr 21:55:07 - [trace] Stopping node debug:18297c3afe9f7448
23 Apr 21:55:07 - [trace] Stopping node function:60d4f05299231f3d
23 Apr 21:55:07 - [trace] Stopping node moment:dee634b0eb19fd96
23 Apr 21:55:07 - [trace] Stopping node dev-input:30f94d14759c1b55
23 Apr 21:55:07 - [trace] Stopping node function:f88972758820db18
23 Apr 21:55:07 - [trace] Stopping node trigger:93eea5bca44ae1d5
23 Apr 21:55:07 - [debug] red/nodes/flows.stop : stopping flow : global
23 Apr 21:55:07 - [trace] [flow:global] stop flow
23 Apr 21:55:07 - [trace] Stopping node telegram bot:ad7ab8444019846b
23 Apr 21:55:07 - [trace] Stopped node inject:3b9da984b6bd127f (56ms)
23 Apr 21:55:07 - [trace] Stopped node function:e5bd371694541cdd (50ms)
23 Apr 21:55:07 - [trace] Stopped node debug:18297c3afe9f7448 (38ms)
23 Apr 21:55:07 - [trace] Stopped node function:60d4f05299231f3d (36ms)
23 Apr 21:55:07 - [trace] Stopped node moment:dee634b0eb19fd96 (34ms)
23 Apr 21:55:07 - [trace] Stopped node dev-input:30f94d14759c1b55 (34ms)
23 Apr 21:55:07 - [trace] Stopped node function:f88972758820db18 (34ms)
23 Apr 21:55:07 - [trace] Stopped node trigger:93eea5bca44ae1d5 (32ms)
23 Apr 21:55:07 - [trace] Stopped node telegram sender:fc436b5f4496cac8 (83ms)
23 Apr 21:55:07 - [trace] Stopped node telegram receiver:ef4078259a03ca02 (58ms)
23 Apr 21:55:09 - [trace] Stopped node telegram bot:ad7ab8444019846b (1708ms)
23 Apr 21:55:09 - [info] Stopped flows
23 Apr 21:55:09 - [trace] runtime event: {"id":"runtime-state","payload":{"state":"stop"},"retain":true}

Temporarily rename the .node-red folder and restart node-red. That will recreate the folder with an empty flows file. Add a couple of nodes and deploy it, then try stopping node red and see if it is ok. If it is ok then it is something in your flow or installed nodes.
Remove the new .node-red and replace the original and restart node-red and you should be back as before.
I notice that the devoloper of node-red-contrib-dev-input said 8 years ago when it was last released that it was highly unstable, so it would be worth removing that one first.
Otherwise, is node-red spawning any other processes? Play-audio for example? I don't know what would happen if you tried to shut down while something is playing.

thank you for help, I confirm you that if I let it create a new folder it quits without problem. Probably an old module, but that one I've installed later the problem, so it should be something else. I'm not playing audio, I've just installed telegram, banana ir receiver (and I removed it, maybe somthing left?).
How could I now which module cause? Should I rename temporarely folders of modules involved and restart NR? is it safe?

Check in the menu Configuration Nodes, click at the top Unused and select and delete any that you find there. Then Deploy.

I did, there is only the telegram bot config node, and nothing unused, thsi installation is quite fresh, I've installed few things only.
So shoud I rename folderst and start NR till I find when it quits?

I did an experiment, I killed NR, renamed the flows file and start NR with a black flow but during loading I had an error:


24 Apr 16:27:28 - [info] Node-RED version: v3.0.2
24 Apr 16:27:28 - [info] Node.js  version: v12.22.9
24 Apr 16:27:28 - [info] Linux 5.15.93-sunxi arm LE
24 Apr 16:27:35 - [info] Loading palette nodes
24 Apr 16:27:37 - [debug] Module: node-red-contrib-dev-input 0.0.1 /home/pi/.node-red/node_modules/.node-red-contrib-dev-input-master-wkEQH2Qr
24 Apr 16:27:37 - [debug] Module: node-red-contrib-buffer-parser 3.2.2 /home/pi/.node-red/node_modules/node-red-contrib-buffer-parser
24 Apr 16:27:37 - [debug] Module: node-red-contrib-moment 4.0.0 /home/pi/.node-red/node_modules/node-red-contrib-moment
24 Apr 16:27:37 - [debug] Module: node-red-contrib-telegrambot 15.0.1 /home/pi/.node-red/node_modules/node-red-contrib-telegrambot
24 Apr 16:27:37 - [debug] Module: node-red-node-pi-gpio 2.0.6 /home/pi/.node-red/node_modules/node-red-node-pi-gpio
24 Apr 16:27:37 - [debug] Module: node-red-node-ping 0.3.3 /home/pi/.node-red/node_modules/node-red-node-ping
24 Apr 16:27:37 - [debug] Module: node-red-node-random 0.4.1 /home/pi/.node-red/node_modules/node-red-node-random
24 Apr 16:27:37 - [debug] Module: node-red-node-serialport 1.0.3 /home/pi/.node-red/node_modules/node-red-node-serialport
24 Apr 16:27:37 - [debug] Module: node-red-node-smooth 0.1.2 /home/pi/.node-red/node_modules/node-red-node-smooth
24 Apr 16:27:52 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
24 Apr 16:27:53 - [info] Settings file  : /home/pi/.node-red/settings.js
24 Apr 16:27:53 - [info] Context store  : 'default' [module=memory]
24 Apr 16:27:53 - [info] User directory : /home/pi/.node-red
24 Apr 16:27:53 - [warn] Projects disabled : editorTheme.projects.enabled=false
24 Apr 16:27:53 - [info] Flows file     : /home/pi/.node-red/flows.json
24 Apr 16:27:53 - [info] Creating new flow file
24 Apr 16:27:53 - [debug] loaded flow revision: d751713988987e9331980363e24189ce
24 Apr 16:27:53 - [debug] red/runtime/nodes/credentials.load : no user key present
24 Apr 16:27:53 - [debug] red/runtime/nodes/credentials.load : using default key
24 Apr 16:27:53 - [debug] red/runtime/nodes/credentials.load : keyType=system
24 Apr 16:27:53 - [warn]

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

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

24 Apr 16:27:53 - [trace] runtime event: {"id":"runtime-state","retain":true}
24 Apr 16:27:53 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"d751713988987e9331980363e24189ce"},"retain":true}
24 Apr 16:27:53 - [info] Server now running at http://127.0.0.1:1880/
24 Apr 16:27:53 - [error] Uncaught Exception:
24 Apr 16:27:53 - [error] Error: accept EINVAL
    at TCP.onconnection (net.js:1530:24)
pi@orangepizero:~$

I have just noticed that you are using an obsolete and unsupported version of node.js. Node red 3.0 requires at least nodejs 14.

can you kindly tell me how can I update it? WIll 14 work on Orange Pi zero? If not, how can I downgrade safely NR? Thanks

I don't know anything about the orange pi. If it is the same as the normal pi then you can use the install script from the node red docs Running on a pi. I am on my phone but you should be able to find it.

I've tried to update:

root@orangepizero:~# apt install nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
nodejs is already the newest version (12.22.9~dfsg-1ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

I've also run n latest and now I have
root@orangepizero:~# npm -v
9.6.4
Bevore I had 8.xx I don't remember, and now NR doesn't work more


pi@orangepizero:~$ node-red
Segmentation fault
pi@orangepizero:~$

I've tried install 2.2.2 but the command line doesn't work, it exit

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --nodered-version="2.2.2"

Running Node-RED install for user pi at /home/pi on ubuntu

Node-RED v3.x no longer supports Nodejs 12

  You can force an install of node 14, 16  or 18 by using the --node14, --node16 or --node18 parameter.
  However doing so may break some nodes that may need re-installing manually.
  Generally it is recommended to update all nodes to their latest versions before upgrading.

  If you wish to stay on nodejs 12 you can update to the latest Node-RED 1.x or 2.x version by adding
  --nodered-version="1.3.7" or --nodered-version="2.2.2" to that install command. If in doubt this is the safer option.
  Please backup your installation and flows before upgrading.

  Note: not all embedded hardware can be updated via this method - please check before proceeding.

  Exiting now.
pi@orangepizero:~$ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --nodered-version="2.2.2"

I really don't know how to deal with this, how to use options, on the page there isn't any example to clear it. Itanks for help
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) $0 --node16 doesn't work

What is that $0 doing there? Try this

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16

Because I've opened the url and inside the script I've read

usage() {
  cat << EOL
Usage: $0 [options]

Options:
  --help            display this help and exit
  --confirm-root    install as root without asking confirmation
  --confirm-install confirm installation without asking confirmation
  --confirm-pi      confirm installation of PI specific nodes without asking confirmation
  --skip-pi         skip installing PI specific nodes without asking confirmation
  --restart         restart service if install succeeds
  --allow-low-ports add capability to bind to ports below 1024 (default is disallow)
  --update-nodes    run npm update on existing installed nodes (within scope of package.json)
  --no-init         don't ask to initialise settings if they don't exist
  --nodered-user    specify the user to run as, useful for installing as sudo - e.g. --nodered-user=pi
  --nodered-version if not set, the latest version is used - e.g. --nodered-version="3.0.1"
  --node12          if set, forces install of major version of nodejs 12 LTS
  --node14          if set, forces install of major version of nodejs 14 LTS
  --node16          if set, forces install of major version of nodejs 16 LTS
  --node18          if set, forces install of major version of nodejs 18 LTS
                    if none set, install nodejs 16 LTS if nodejs version is less than 14,
                    otherwise leave current install

ok I've installed and now nodejs is @16, but the problem still. How an I proceed forward? Thank you

After changing the nodejs version you may have to rebuild nodes. Go into the .node-red folder and run
npm install
If the problem still persists then I think you may have to use the sledgehammer technique. Rename the .node-red folder again and restart node-red to regenerate it. Then copy just the flows.json file across to the new folder and restart node-red again. Node red should complain that there are missing installed nodes. Disable all the tabs (double click each tab and there is a button at bottom left) and it should then Deploy without errors. You can then enable the tabs one at a time and install the nodes needed for that tab. At each stage check you can still shut down using Ctrl-C. Keep a record of what you have done at each stage. At some point it will presumable fail.

I did, thanks for the suggestions, yes the module I intalled manually is the cause, if I disable it it quits on a resonable time.
So how can I fix it maybe it's written with old NR code/not compatible with new version3? May you kindly have a look to it? There are only few lines. I really don't know where can be the problem..
Maybe the way I installed it? I've copied the folder into the modules volder, then on .node-red path I ran:

pi@orangepizero:~/.node-red$ npm list node-red-contrib-dev-input-master
node-red-project@0.0.1 /home/pi/.node-red1
└── (empty)

pi@orangepizero:~/.node-red$

Thank you a lot for support

I have just noticed that the output refers on the folder .node-red1, which is the backuped folder I renamed..
Why npm behave so, it probably had registered the module already on the other folder, but has no sense.
Npm makes me things ever more difficult ((

this time I ran the command on the module's folder:

pi@orangepizero:~/.node-red/node_modules$ npm list node-red-contrib-dev-input-master
node-red-project@0.0.1 /home/pi/.node-red
└── node-red-contrib-dev-input-master@npm:node-red-contrib-dev-input@0.0.1 extraneous

then I run node red and I see the dev-input module became enabled automatically, before it was disabled. ANyway it works like before and also now I can't quit NR.

Go read the node’s GitHub page:

I think you need to look for another node.