Raspberry Pi - start service at boot - clarification

The installation notes for Raspberry pi explain the need to start node-red with the specific Pi command and pass the parameter that tells Node.js to free up space earlier than it would normally do.

node-red-pi --max-old-space-size=256

But it does not explain whether you need, or how, to do the same thing if you set it up as a service to start at boot.

Could somebody clarify if it is wise/necessary to use the special Pi command in that case, and if so - how.

Thanks

I've been running Node-RED on PiZeros for years without doing that command

And all my Pi are running full desktops so that would make them even more memory constrained

Not noticed any issues at all

Thanks! I had not noticed any negative effect, but was just curious and did not want to wake up one morning to find my Pi's were memory bound!

If you use the recommended install script then it sets up a reasonable default value in the systemd startup script.

When you run as a service it uses the nodered.service file we configure to start up... this is usually at /lib/systemd/system/nodered.service - so you can look at that to see how we have defaulted it to your device. (and indeed edit it if you want)

The option helps Node.js steer when it does garbage collection of allocated space that is no longer needed. Because GC is an overhead, it isn't done unless really needed.

So the option wouldn't have any impact unless you happen to hit a situation where you are filling up and emptying the stack quite rapidly coupled with constrained memory.

It was recommended at one stage by Nick & Dave because we were seeing quite a few cases of out-of-memory issues and constraining the GC process seemed to help. Since then, perhaps node.js and the underlying V8 engine have gotten more efficient. Perhaps the CG process is also now more efficient. Maybe Node-RED is also more efficient.

But you are right. For most people, most of the time, they will not get much, if any benefit from that option.

I think it is /lib/systemd/system/nodered.service on a pi.

1 Like

The following will tell you where everything is actually located:

home@home:~$ ls -la /etc/systemd/system
total 40
drwxr-xr-x 10 root root 4096 Dec  8 23:02 .
drwxr-xr-x  5 root root 4096 Dec  6 06:32 ..
drwxr-xr-x  2 root root 4096 Feb  8  2020 bluetooth.target.wants
lrwxrwxrwx  1 root root   42 Feb  8  2020 dbus-fi.w1.wpa_supplicant1.service -> /lib/systemd/system/wpa_supplicant.service
lrwxrwxrwx  1 root root   37 Feb  8  2020 dbus-org.bluez.service -> /lib/systemd/system/bluetooth.service
lrwxrwxrwx  1 root root   40 Dec  8 23:02 dbus-org.freedesktop.ModemManager1.service -> /lib/systemd/system/ModemManager.service
lrwxrwxrwx  1 root root   53 Dec  8 23:02 dbus-org.freedesktop.nm-dispatcher.service -> /lib/systemd/system/NetworkManager-dispatcher.service
lrwxrwxrwx  1 root root   45 Feb  8  2020 dbus-org.freedesktop.timesync1.service -> /lib/systemd/system/systemd-timesyncd.service
drwxr-xr-x  2 root root 4096 Feb  8  2020 getty.target.wants
drwxr-xr-x  2 root root 4096 Dec  8 23:02 graphical.target.wants
lrwxrwxrwx  1 root root   36 Feb  9  2020 influxd.service -> /lib/systemd/system/influxdb.service
drwxr-xr-x  2 root root 4096 Dec 31 13:52 multi-user.target.wants
drwxr-xr-x  2 root root 4096 Dec  8 23:02 network-online.target.wants
lrwxrwxrwx  1 root root   39 Feb 10  2020 nrmain.service -> /home/home/nrmain/system/nrmain.service
drwxr-xr-x  2 root root 4096 Dec  8 23:01 sockets.target.wants
lrwxrwxrwx  1 root root   31 Feb  8  2020 sshd.service -> /lib/systemd/system/ssh.service
drwxr-xr-x  2 root root 4096 Feb  8  2020 sysinit.target.wants
lrwxrwxrwx  1 root root   35 Feb  8  2020 syslog.service -> /lib/systemd/system/rsyslog.service
drwxr-xr-x  2 root root 4096 Feb  9  2020 timers.target.wants
home@home:~$

Or possibly (in the case of Ubuntu and Raspbian)
ls -la /etc/systemd/system/multi-user.target.wants/
It doesn't appear in /etc/systemd/system.

I think the best way is
sudo systemctl status nodered
which will tell you where it actually is.

Thank you to everyone for their swift responses!

The config is in /lib/systemd/system on mi Pi and the setting is
Environment="NODE_OPTIONS=--max_old_space_size=512"

I'm going to leave well alone for now as nobody seems to have had a problem (and neither have I!) with that setting, but at least I now know where to look!

Matter closed, thanks once again!

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