npm and node_index.js high CPU load

Having issues with your DietPi installation or found a bug? Post it here.
User avatar
Joulinar
Posts: 4820
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

novitibo wrote: Mon Jan 25, 2021 11:21 pm
Joulinar wrote: Mon Jan 25, 2021 11:17 pm so it is running fine now? No CPU spikes anymore?
node-red isn't restarting, but node and npm processes are CPU spiking
than it is not stopping correctly?

using systemctl stop node-red.service is stopping the whole stuff for me and there are no further node or npm processes
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

Joulinar wrote: Mon Jan 25, 2021 11:21 pm well you could create a script stating node, do a sleep 120 and stop node again. This than to be scheduled on cron
how can I create script for sleep if PID keeps changing?
User avatar
Joulinar
Posts: 4820
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

usually it should be

Code: Select all

systemctl start node-red.service
sleep 120
systemctl stop node-red.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

Joulinar wrote: Mon Jan 25, 2021 11:25 pm
novitibo wrote: Mon Jan 25, 2021 11:21 pm
Joulinar wrote: Mon Jan 25, 2021 11:17 pm so it is running fine now? No CPU spikes anymore?
node-red isn't restarting, but node and npm processes are CPU spiking
than it is not stopping correctly?

using systemctl stop node-red.service is stopping the whole stuff for me and there are no further node or npm processes
in this whole is the rabbit :?
node and npm processes are still alive somehow after I stop the node-red :(
User avatar
Joulinar
Posts: 4820
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

how many processes you have? at least in my test system it is a single process that gone as soon as I stop node-red. Are you running something else?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

I'm running those: (sorry for bad formatting)
[ ] 0 OpenSSH Client: Feature-rich SSH, SFTP and SCP client │
│ [ ] 5 ALSA: linux sound system │
│ [ ] 6 Xserver: linux display system │
│ [ ] 7 FFmpeg: audio & visual libary │
│ [ ] 9 Node.js: javascript runtime │
│ [ ] 16 Build-Essentials: common packages for compile │
│ [ ] 17 Git Client: git clone etc │
│ [ ] 27 TasmoAdmin: Website to manage ESP8266 devices flashed with Tasmota │
│ [ ] 67 No-IP: Dynamic DNS update client │
│ [ ] 69 RPi.GPIO: gpio interface library for rpi (python) │
│ [ ] 72 I2C: enables support for i2c based hardware │
│ [ ] 73 Fail2Ban: prevents brute-force attacks with ip ban │
│ [ ] 81 LLSP: lighttpd | sqlite | php │
│ [ ] 82 LLMP: lighttpd | mariadb | php │
│ [ ] 84 Lighttpd: webserver │
│ [ ] 87 SQLite: database │
│ [ ] 88 MariaDB: database │
│ [ ] 89 PHP: Hypertext Preprocessor for dynamic web content │
│ [ ] 90 phpMyAdmin: optional mysql admin tools │
│ [ ] 91 Redis: optional non-sql database store │
│ [ ] 92 Certbot: Obtain and renew Let's Encrypt SSL certs for HTTPS │
│ [ ] 93 Pi-hole: block adverts for any device on your network │
│ [ ] 96 Samba Server: feature-rich file server │
│ [ ] 102 Rsyslog: system logging │
│ [ ] 103 DietPi-RAMlog: minimal, optimised logging │
│ [ ] 105 OpenSSH Server: Feature-rich SSH server with SFTP and SCP support │
│ [ ] 114 Nextcloud: File sync, sharing and collaboration platform │
│ [ ] 115 Webmin: web interface system management │
│ [ ] 122 Node-RED: tool for wiring devices, APIs and online services │
│ [ ] 123 Mosquitto: MQTT messaging broker │
│ [ ] 126 LibSSL1.0.0: backwards compatibility (stretch, buster, bullseye) │
│ [ ] 150 Mono: runtime libraries and repo │
│ [ ] 152 Avahi-Daemon: hostname broadcast (mac, pc bonjour) │
│ [ ] 157 Home Assistant: open-source home automation platform │
│ [ ] 170 UnRAR: unarchiver for .rar files
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

pstree
systemd─┬─agetty
├─alsactl
├─avahi-daemon───avahi-daemon
├─bluetoothd
├─cron
├─dbus-daemon
├─fail2ban-server───2*[{fail2ban-server}]
├─hciattach
├─homeassistant-s───hass───28*[{hass}]
├─lighttpd
├─miniserv.pl
├─mosquitto
├─mysqld───32*[{mysqld}]
├─nmbd
├─node───6*[{node}]
├─node───10*[{node}]
├─noip2
├─php-fpm7.3───4*[php-fpm7.3]
├─pihole-FTL───6*[{pihole-FTL}]
├─redis-server───3*[{redis-server}]
├─rngd───3*[{rngd}]
├─rpcbind
├─rsyslogd───3*[{rsyslogd}]
├─smbd─┬─cleanupd
│ ├─lpqd
│ └─smbd-notifyd
├─sshd───sshd───sshd───bash───su───bash───pstree
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─vmtouch
└─wpa_supplicant
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

after systemctl stop node-red.service
only node 6 is gone :?

pstree
systemd─┬─agetty
├─alsactl
├─avahi-daemon───avahi-daemon
├─bluetoothd
├─cron
├─dbus-daemon
├─fail2ban-server───2*[{fail2ban-server}]
├─hciattach
├─homeassistant-s───hass───28*[{hass}]
├─lighttpd
├─miniserv.pl
├─mosquitto
├─mysqld───32*[{mysqld}]
├─nmbd
├─node───10*[{node}]
├─noip2
├─php-fpm7.3───4*[php-fpm7.3]
├─pihole-FTL───6*[{pihole-FTL}]
├─redis-server───3*[{redis-server}]
├─rngd───3*[{rngd}]
├─rpcbind
├─rsyslogd───3*[{rsyslogd}]
├─smbd─┬─cleanupd
│ ├─lpqd
│ └─smbd-notifyd
├─sshd───sshd───sshd───bash───su───bash───pstree
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─vmtouch
└─wpa_supplicant
User avatar
Joulinar
Posts: 4820
Joined: Sat Nov 16, 2019 12:49 am

Re: npm and node_index.js high CPU load

Post by Joulinar »

strange that it is not gone. As well that you have 2 node processes. Can you use htop and filter (F4) for node
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
novitibo
Posts: 120
Joined: Mon Feb 29, 2016 5:11 pm

Re: npm and node_index.js high CPU load

Post by novitibo »

after node-red is stopped this remains (on and off):

USER root Command node index.js
USER root Command sh -c node index.js
USER root Command node /usr/bin/npm start
Post Reply