Skip to content
Ivaylo Ivanov edited this page Jan 16, 2016 · 5 revisions

Defined in Esrol-servers and implemented in Esrol-server-app

Node Cluster API is implemented as a component, so everything that you need to do is to enable it from config.json file.

app/config/config.json

"cluster": {
  "enabled": true,
  "cores": "auto"
},
"servers": {
  "http": {
    "enabled": false,
    "port": 3333,
    "methods": ["get", "put", "post", "delete"],
    "webSockets": false,
    "cluster": false
  },
  "https": {
    "enabled": false
  },
  "tcp": {
    "enabled": true,
    "port": 3334,
    "allowHalfOpen": false,
    "pauseOnConnect": false
  },
  "udp": {
    "type": "udp4",
    "enabled": false,
    "port": 3335
  }
}

If cores property has an auto value, require('os').cpus().length will be used. If you want, you can specify the number by putting an int value - 4 - for four cores. If you need more information about cluster, please refer to Node Cluster API

Note

If you have enabled HTTP server and want to run in cluster, make sure that you have enabled cluster it in both places:
app/config/config.json

"cluster": {
  "enabled": true,
  "cores": "auto"
},
"servers": {
  "http": {
    "enabled": true,
    "port": 3333,
    "methods": ["get", "put", "post", "delete"],
    "webSockets": false,
    "cluster": true
  },
  "https": {
    "enabled": false
  },
  "tcp": {
    "enabled": false,
    "port": 3334,
    "allowHalfOpen": false,
    "pauseOnConnect": false
  },
  "udp": {
    "type": "udp4",
    "enabled": false,
    "port": 3335
  }
}

Clone this wiki locally