Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permanently change Node call stack size

Tags:

node.js

I want to increase the --stack-size option for nodejs system-wide.

I know I can do this on a per invocation basis like this:

node --stack-size=10000 <app>

But I want to set the stack size system wide to this value for all users and for cron tasks.

I'm on Ubuntu 13.

like image 921
Henry Avatar asked Mar 02 '26 05:03

Henry


2 Answers

You can:

  1. Rename /usr/bin/node (or whatever you actual path to node is) to /usr/bin/node_bin

  2. Create shell script in place of old node executable (at /usr/bin/node) with following content:

    #!/bin/bash
    /usr/bin/node_bin --stack-size=10000 $@

This way you don't have to change absolute references to node in all the cron scripts.

like image 116
Daniel Avatar answered Mar 03 '26 21:03

Daniel


Context

To iterate on https://stackoverflow.com/users/8109341/daniel 's answer:

On Ubuntu, I had to wrap $@ in double quotes: "$@", otherwise passing arguments would break:

E.g.:

Running npx ganache-cli -m "strike artwork yard vault enhance despair online sock feed cactus subject rebela" -i 15

Would have process.argv evaluated to:

[ '/usr/bin/node_bin',
  '/home/daniel/repos/aragon/aragen/node_modules/.bin/ganache-cli',
  '-m',
  'strike',
  'artwork',
  'yard',
  'vault',
  'enhance',
  'despair',
  'online',
  'sock',
  'feed',
  'cactus',
  'subject',
  'rebel',
  '-i',
  '15']

instead of:

[ '/usr/bin/node_bin',
  '/home/daniel/repos/aragon/aragen/node_modules/.bin/ganache-cli',
  '-m',
  'strike artwork yard vault enhance despair online sock feed cactus subject rebel',
  '-i',
  '15']

TL;DR

  1. Rename the node binary: sudo mv /usr/bin/node /usr/bin/node_bin
  2. Create the shell script:
cat << EOF | sudo tee /usr/bin/node
#!/bin/bash
/usr/bin/node_bin --stack-size=4096 "\$@"
EOF
  1. Make the shell script executable: sudo chmod +x node
like image 29
Daniel Constantin Avatar answered Mar 03 '26 21:03

Daniel Constantin