Search code examples
node.jsreststronglooploopbackjs

Strongloop controller in cluster mode results in EADDRINUSE


I'm building an API with Strongloops's Loopback. I'm following this tutorial and so far it's working when I run the app with

slc run

However, if I try to run the app in clustered mode (to take advantage of a dual core server) the second process throws an EADDRINUSE error.

My config.json reads

{
    "restApiRoot": "/v1",
    "host": "0.0.0.0",
    "port": 5000,
    "url": "http://0.0.0.0:5000/"
}

much like in the example (except for the port). I haven't been able to find documentation of how (or if) should I modify this config.

Has anyone ran slc in cluster mode? Does anyone have experience on running Node in clustered mode? (I know foreman allows something like this).

Thanks!


Solution

  • What command did you use to run the app in a cluster?

    You should use something like

    slc run --cluster cpus
    

    See http://docs.strongloop.com/display/SLC/slc+run for docs. I just ran the app from https://github.com/strongloop/loopback-example-datasourceAPI.git with this command and it ran OK for me.

    BTW, docs for config.json are in http://docs.strongloop.com/display/LB/config.json.

    Rand