-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Pass instance id to app as environment variable #1143
Comments
Hi, |
Any chance to make it configurable? |
I'm not sure I'm understanding this. |
Let me explain: I need this ID to get passed to the instance itself (probably through environment variables). Does that make sense? |
You can set a
|
@soyuka not sure i understand... can you give me an example? Define the port where? |
Lets say i have the following
I want to be able to do this in my
and that PM2 will populate the NODE_APP_INSTANCE id by itself. (being one of 0 to 5 for this example) right now i solve it using a different script to start the instances myself:
but that takes the point out of pm2's multi instance feature... |
Ok I got it. we could implement this indeed. |
@shaharmor nvm about the @jshkurti Maybe he want's to use something like HAProxy in front of the web app to load-balance to one of his pre-defined ports? |
Actually thats exactly what i want, but i can think of other usages for On Thursday, April 2, 2015, Antoine Bluchet notifications@github.com
|
Okay I'm going to implement this feature :) |
I think having it configureable in the json file would be best, but if you On Thursday, April 2, 2015, Joni Shkurti notifications@github.com wrote:
|
@jshkurti Depending on the setup, you might want to start multiple instances, in a port range, and have your webserver (eg. nginx) handle the distribution - instead of using the cluster mode. |
It's done :)
|
Works great! When will this be in stable version? |
Seems to be working just fine here as well.. thanks. |
But there's no |
Only works in cluster_mode. |
well I would like to use this feature ( process.env.NODE_APP_INSTANCE ) without the cluster mode. Does that make any difference ? |
@sarthakz9, isn't there always just a single instance in that case? |
When starting pm2 with multiple instances for a specific app, it would really help a lot if the app itself would get an Int representing its id in the series of instances.
For example, given a pm2 configuration that loads 3 instances:
app1 - instance id 0
app2 - instance id 1
app3 - instance id 2
In the node-config module they use the NODE_APP_INSTANCE env variable, but setting it in the pm2.json file itself can also work.
The text was updated successfully, but these errors were encountered: