SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
298 stars 150 forks source link

Reinstalling all plugins very resource hungry #1741

Open tkurki opened 1 month ago

tkurki commented 1 month ago

I tried to reinstall all my plugins on my PRi3 by removing .signalk/node_modules and simply running npm install in .signalk.

This turned out to be problematic in two ways:

pstree showed a number of npm install processes and I think i saw node-pre-gyp in top also.

Doing the same operation manually, one by one (under docker run -it --rm -v /home/pi/signalk-settings:/home/node/.signalk --entrypoint /bin/sh signalk/signalk-server:master) succeeded without breaking a sweat.

To me this suggests that just given a package.json npm install goes all out, with parallel operations, which may be just too resource intensive for some typical platforms that Signal K is used on.

I can think of two solutions here:

KEGustafsson commented 1 month ago

npm config get maxsockets default is 15. If this is tuned, would it make any difference e.g. npm config set maxsockets 5 or even smaller amount?

Also npm i --max-old-space-size=250 might be viable solution to limit memory usage.