Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm2-runtime: env spawn E2BIG #4725

Closed
dmpvost opened this issue May 27, 2020 · 6 comments
Closed

pm2-runtime: env spawn E2BIG #4725

dmpvost opened this issue May 27, 2020 · 6 comments
Labels

Comments

@dmpvost
Copy link

dmpvost commented May 27, 2020

What's going wrong?

When I start my app with pm2-runtime in gitlab CI.
The current env is inherint from gitlab env.

And it appear that it's too big. PM2 error: Trace: Error: spawn E2BIG
The command filter_env is not available for pm2-runtime

2020-05-27T15:49:39: PM2 error: Trace: Error: spawn E2BIG
     at ChildProcess.spawn (internal/child_process.js:407:11)
     at spawn (child_process.js:548:9)
     at fork (child_process.js:116:10)
     at createWorkerProcess (internal/cluster/master.js:134:10)
     at EventEmitter.cluster.fork (internal/cluster/master.js:169:25)
     at Object.nodeApp (/usr/local/lib/node_modules/pm2/lib/God/ClusterMode.js:48:21)
     at Object.executeApp (/usr/local/lib/node_modules/pm2/lib/God.js:245:9)
     at inject (/usr/local/lib/node_modules/pm2/lib/God.js:159:18)
     at Object.injectVariables (/usr/local/lib/node_modules/pm2/lib/God.js:586:10)
     at /usr/local/lib/node_modules/pm2/lib/God.js:157:9 {
   errno: 'E2BIG',
   code: 'E2BIG',
   syscall: 'spawn'
 }

How could we reproduce this issue?

Try to start pm2-runtime under GitlabCI

Supporting information

$ pm2 report

keymetrics/docker-pm2#81

@dmpvost dmpvost changed the title pm2-runtime spawn E2BIG pm2-runtime: env spawn E2BIG May 27, 2020
@stale
Copy link

stale bot commented Jun 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 26, 2020
@stale stale bot closed this as completed Jul 10, 2020
@himanshurobo
Copy link

himanshurobo commented Feb 17, 2021

Sharing error logs : -

PM2        |     at EventEmitter.cluster.fork (internal/cluster/master.js:169:25)
PM2        |     at Object.nodeApp (/usr/lib/node_modules/pm2/lib/God/ClusterMode.js:48:21)
PM2        |     at Object.executeApp (/usr/lib/node_modules/pm2/lib/God.js:245:9)
PM2        |     at inject (/usr/lib/node_modules/pm2/lib/God.js:159:18)
PM2        |     at Object.injectVariables (/usr/lib/node_modules/pm2/lib/God.js:586:10)
PM2        |     at /usr/lib/node_modules/pm2/lib/God.js:157:9 {
PM2        |   errno: 'E2BIG',
PM2        |   code: 'E2BIG',
PM2        |   syscall: 'spawn'
PM2        | }
PM2        |     at Object.God.logAndGenerateError (/usr/lib/node_modules/pm2/lib/God/Methods.js:34:15)
PM2        |     at Object.nodeApp (/usr/lib/node_modules/pm2/lib/God/ClusterMode.js:50:11)
PM2        |     at Object.executeApp (/usr/lib/node_modules/pm2/lib/God.js:245:9)
PM2        |     at inject (/usr/lib/node_modules/pm2/lib/God.js:159:18)
PM2        |     at Object.injectVariables (/usr/lib/node_modules/pm2/lib/God.js:586:10)
PM2        |     at /usr/lib/node_modules/pm2/lib/God.js:157:9
PM2        |     at /usr/lib/node_modules/pm2/node_modules/async/internal/map.js:22:9
PM2        |     at replenish (/usr/lib/node_modules/pm2/node_modules/async/internal/eachOfLimit.js:81:17)
PM2        |     at /usr/lib/node_modules/pm2/node_modules/async/internal/eachOfLimit.js:86:9
PM2        |     at _asyncMap (/usr/lib/node_modules/pm2/node_modules/async/internal/map.js:20:12)

@dmpvost
Copy link
Author

dmpvost commented Feb 17, 2021

I forgot to share my twix, rewrite the variable env only with my usage.

The problem is that gitlab have too much argument in args.

I have reset all variable env just for this command with env -i
and add just the strict minimum arguments

env -i PWD="/app" HOME="/root" NODE_VERSION="12.13.0" pm2-runtime

Work fine

@chemsseddine
Copy link

@dmpvost pm2-runtime will not be available if you are doing env -i , how are you managing this ?

@dmpvost
Copy link
Author

dmpvost commented Mar 15, 2023

Like that, I just copy paste my case, some variable are maybe useless for you

if [ "${CI_ENV}" == "true" ]
then
  env -i NODE_OPTIONS=--max-http-header-size=79000 ROARR_LOG="true" YARN_VERSION="1.19.1" NODE_ENV="${NODE_ENV}" PWD="/app" HOME="/root" NODE_VERSION="12.13.0" TERM="xterm" SHLVL="1" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" pm2-runtime ${pm2_conf} --env "${target}" --node-args="--max-http-header-size=80384" --max-http-header-size=81000
else
  pm2-runtime ${pm2_conf} --env "${target}" --node-args="--max-http-header-size=80384" --max-http-header-size=81000
fi

@chemsseddine
Copy link

great thanks a lot @dmpvost , I think that PATH env var is important

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants