I am a node newbie so please be gentle. :)
I have an express app that works just fine. I want to move this into production soon and was hoping to use pm2 to do clustering and management. However it seems either I am using pm2 incorrectly or the app is written incorrectly.
When I run, pm2 start server.js everything runs fine. However when I use pm2 start server.js -i 2 -x then in the logs I can see that one of the child processes throws a EADDRINUSE exception. When I test my app via jmeter I can see that only one child process is using memory and cpu and the other one is idle.
My express app is simple (some parts omitted):
var express = require('express');
var app = express();
var router = express.Router();
// routes go here
app.use('/', router);
var port = config.port;
app.listen(port);
module.exports = app;
Is my app the culprit or have I hit some kind of a bug here?
Version info:
Node - 0.10.33
OS - OS X v10.8.5
PM2 - 0.11.1
Edit: I checked this with Node version 0.11.14 and it happens there also.
pm2 start server.js -i 2 -x
-i specifies instances
-x specifies fork mode (see readme)
You can't use fork mode with more than 1 instance, try the cluster mode or don't specify instances.
pm2 start server.js -i max should work just fine :)
Most helpful comment
pm2 start server.js -i maxshould work just fine :)