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

interpreter ignored when using cluster mode #1575

Closed
creynders opened this issue Sep 2, 2015 · 10 comments
Closed

interpreter ignored when using cluster mode #1575

creynders opened this issue Sep 2, 2015 · 10 comments

Comments

@creynders
Copy link

This works as expected:

  • pm2 start app -i 2
  • pm2 start app --interpreter=/usr/local/n/versions/node/0.12.0/bin/node

But when combined the interpreter argument is ignored:

  • pm2 start app -i 2 --interpreter=/usr/local/n/versions/node/0.12.0/bin/node

The same applies when declared in a json file

@Unitech
Copy link
Owner

Unitech commented Sep 3, 2015

Hello,

Yes in fork mode you can defined the interpreter but in cluster mode it's not possible as we rely on the current Node.js version that runs PM2 to use the cluster module (https://github.com/Unitech/PM2/blob/master/lib/God/ClusterMode.js#L50)

@Unitech Unitech closed this as completed Sep 3, 2015
@creynders
Copy link
Author

Hmm, yes of course, that makes sense. A real pity though.

@tangxinfa
Copy link

Suggest documention it(in npm --help output or some where else), i waste many time to investigate the same problem:(

@jippi
Copy link

jippi commented Sep 7, 2016

I stumbled on this as well

@Unitech I would like to be able to overwrite the interpreter, since i depend on envconsul ( github.com/hashicorp/envconsul/ ) to inject the relevant ENV variables to my node script

Basically i want to prefix whatever interpreter is in cluster mode with a command to enrich the environment :)

Any way to achieve this? Would like to not write the env to a yaml file, as it significantly increases the risk and complexity of just pulling it out directly from Consul

update i have a hack work-around to modify $PATH to include my own node "binary" which simply does

#!/bin/bash

/usr/local/bin/envconsul \
   -config /etc/envconsul/config.hcl \
   -prefix apps/frontend/supervisor/frontend-render/env \
   -prefix apps/frontend/env \
   -sanitize \
   -upcase \
   /usr/local/bin/node $@

but would be nice if i could do this from pm2 :)

@vmarchaud
Copy link
Contributor

vmarchaud commented Sep 7, 2016

@jippi PM2 has a hardcoded binary name (which is 'node') for start in cluster mode since we are using the cluster mode of nodejs. By the way you can inject custom env values into your app using PM2 (cf. http://pm2.keymetrics.io/docs/usage/application-declaration/)

@jippi
Copy link

jippi commented Sep 7, 2016

@vmarchaud sure, but being able to wrap the interpreter would be wildly useful, as my example above shows above, that it would be my own responsibility to pass the what-ever i put in interpreter to node (eventually)

Having the environment variables in a static file is not an optimal requirement/pattern for docker and highly flexible environments where these things change quite rapidly and can come from multiple sources.

@vmarchaud
Copy link
Contributor

@jippi Understood but other people might try to use another interpreter in cluster mode and since its wont work, tell us that its our responsibility to verify that the interpreter is node, so yeah, not an easy choice here.

@jippi
Copy link

jippi commented Sep 7, 2016

@vmarchaud would it make sense to have a new config key for this ? e.g. node_bin or something, where i can provide my own path to whatever should be considered a node binary ?

Would also allow me to mix nodejs versions easily under the same pm2 instance :)

@soyuka
Copy link
Collaborator

soyuka commented Sep 7, 2016

I think you can already do this by using NODE_PATH. It's evaluated before PATH in pm2.

@tayden
Copy link

tayden commented Mar 15, 2017

My working workaround is to do:

PATH=/usr/local/n/versions/node/0.12.0/bin:$PATH pm2 start app -i 2

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

No branches or pull requests

7 participants