Using pm2 for the first time, I'm a bit confused about something. I'm running a very simple http server on port 1337 and using pm2 to run it:
var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
server.listen(1337);
and running it as follows:
pm2 start app.js
What I don't understand is, if I execute the above command (pm2 start app.js) several times, pm2 creates more instances of this app without any problem. But isn't there a conflict as all of them are listening on port 1337? And if not, what is the effect of multiple of them running at the same time? If a request comes in, which one does it go to?
Thanks