-
Notifications
You must be signed in to change notification settings - Fork 19
Intro
Phillip Kovalev edited this page Jul 13, 2015
·
2 revisions
$ npm install --save luster
$ echo '{ "app": "worker.js" }' >./luster.conf.json
$ ./node_modules/.bin/luster
{ "server": { "port": 12345 } }
{ "server": { "port": "/var/run/node/unix.*.sock" } }
In the worker.js
use the port value provided by the master:
server.listen(process.env.port);
"workers": 10,
"server": { "port": 10000, "groups": 2 },
Workers 1–5 will listen 10000
, 6–10 will listen 10001
.
Setup the reverse proxy (nginx, haproxy, ...) of your choice with the round-robin balancing.
{ "debug": { "port": 9000 } }
Master will start the workers with the option --debug
.
1st on the port 9000, 2nd on the port 9001, …
npm install luster-some-extension
Add the extensions
section to the config:
extensions: {
"luster-some-extension": { <CONFIG> }
}
Extension for the luster is the regular Node.js module, which exports an object including the configure
function.
module.exports = {
configure: function(config, clusterProcess) {
// setup the extension
}
}
master.registerRemoteCommand('pong', function(sender, state) {
console.log('worker %s is %s', sender.wid, state);
}).remoteCallToAll('ping');
worker.registerRemoteCommand('ping', function(sender) {
sender.remoteCall('pong', 'alive');
});
Master = require('luster/master');
MyMaster = Master.create();
MyMaster.configure(config).run();
- Queues
- Multiple masters in the one process
- Whatever you want!
- Clusterize your app in a minute.
- Attach a remote debugger to any worker.
- Partially managable load balancing.
- Write an extension and distribute it as a Node.js module.
- Compose you own master to orchestrate complex apps.