3

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

For windows, using the same approach as https://stackoverflow.com/users/8109341/daniel 's answer:

  1. Rename C:\Program Files\nodejs\node.exe to C:\Program Files\nodejs\node_origin.exe
  2. Create C:\Program Files\nodejs\node.cmd with the following contents:
@ECHO OFF

SET "NODE_EXE=C:\Program Files\nodejs\node_origin.exe"
echo Running node with '--stack-size=4096'

"%NODE_EXE%" "--stack-size=4096" %*

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.