0
votes

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!

1
Is line 33 to 44 included in your server.js ? Seems like the spawned workers are attaching to same port as server.Alvin K.
Yes, my app has those exact lines. I created the app with slc loopback but that part is identical to the example app.ffflabs

1 Answers

2
votes

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