0

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!

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
ffflabs
  • 17,166
  • 5
  • 51
  • 77
  • 1
    Is line [33 to 44 included](https://github.com/strongloop/loopback-example-app/blob/master/server/server.js) in your server.js ? Seems like the spawned workers are attaching to same port as server. – Alvin K. Aug 14 '14 at 22:08
  • Yes, my app has those exact lines. I created the app with ```slc loopback``` but that part is identical to the example app. – ffflabs Aug 14 '14 at 22:51

1 Answers1

2

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

RandM
  • 231
  • 1
  • 3
  • I was using that same command. Then I tried in my localhost and it ran fine (with 4 cpus). I restarted the dev server and tried again and now it's running. So I guess it was a zombie process after all. Thanks! – ffflabs Aug 14 '14 at 22:55
  • [Tech support](http://dilbert.com/strips/comic/1999-08-04/) from Dilbert comics over a decade ago. – Alvin K. Aug 14 '14 at 23:39
  • I must admit I freak out when I have to reboot an EC2 instance. Half the time the little freaks get locked in a bootloop due to the ephemeral storage failing to automount. At least the new T2 instances don't have any. – ffflabs Aug 15 '14 at 19:07