Possible to run multiple instances of same app on different ports #322

Closed
waygee opened this Issue Feb 24, 2014 · 2 comments

Comments

3 participants
@waygee

waygee commented Feb 24, 2014

Hi,

I wanted to inquire whether it's possible to run my app.js multiple clusters like so:

app.js Cluster1 port 80
….
app.js Cluster2 port 81
….
app.js Cluster 3 port 82
….
app.js Cluster 4 port 83

My hosting provider, Rackspace, has advised me to try to set up this way.

Is this possible to do this under pm2 and have my app.js be running multiple clusters under different ports?

Thanks in advance for your help.

@soyuka

This comment has been minimized.

Show comment
Hide comment
@soyuka

soyuka Jun 13, 2014

Collaborator

You could clone your app 4 times... I think there are better solutions as load-balancing for those kind of things but pm2 can't handle this without some heavy mods.

Collaborator

soyuka commented Jun 13, 2014

You could clone your app 4 times... I think there are better solutions as load-balancing for those kind of things but pm2 can't handle this without some heavy mods.

@rlidwka

This comment has been minimized.

Show comment
Hide comment
@rlidwka

rlidwka Jun 22, 2014

Collaborator
NODE_PORT=80 pm2 start app.js -f
NODE_PORT=81 pm2 start app.js -f
NODE_PORT=82 pm2 start app.js -f
NODE_PORT=83 pm2 start app.js -f

... where NODE_PORT is an arbitrary name that you add as .listen(process.env.NODE_PORT) into your program.

(-f flag is necessary to force re-execution, since pm2 will complain otherwise)

Collaborator

rlidwka commented Jun 22, 2014

NODE_PORT=80 pm2 start app.js -f
NODE_PORT=81 pm2 start app.js -f
NODE_PORT=82 pm2 start app.js -f
NODE_PORT=83 pm2 start app.js -f

... where NODE_PORT is an arbitrary name that you add as .listen(process.env.NODE_PORT) into your program.

(-f flag is necessary to force re-execution, since pm2 will complain otherwise)

soyuka added a commit that referenced this issue Jun 22, 2014

@soyuka soyuka referenced this issue Sep 2, 2014

Closed

Multiple clusters #675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment