Permalink
Browse files

stand-alone docs

  • Loading branch information...
1 parent 9b0a269 commit 8ec1a99ae6fa4396625ddcd3db917f0129f22435 @tj tj committed Aug 1, 2011
Showing with 20 additions and 1 deletion.
  1. +20 −1 docs/api.md
View
@@ -99,6 +99,25 @@
Receives an object with state preserved by the `restarting` even,
patched in the previous master.
+### Stand-alone workers
+
+ To run Cluster "stand-alone", aka without an HTTP server you may invoke `.start()` instead of `.listen()` the rest of Cluster remains identical, this is fantastic for processing job queues etc. For example:
+
+ var cluster = require('../');
+
+ var proc = cluster()
+ .set('workers', 4)
+ .use(cluster.debug())
+ .start();
+
+ if (proc.isWorker) {
+ var id = process.env.CLUSTER_WORKER;
+ console.log(' worker #%d started', id);
+ setInterval(function(){
+ console.log(' processing job from worker #%d', id);
+ }, 3000);
+ }
+
### Master#state
Current state of the master process, one of:
@@ -200,4 +219,4 @@
### Master#kill([signal])
- Sends __SIGTERM__ or `signal` to all worker processes. This method is used by `Master#restart()`, `Master#close()` etc.
+ Sends __SIGTERM__ or `signal` to all worker processes. This method is used by `Master#restart()`, `Master#close()` etc.

0 comments on commit 8ec1a99

Please sign in to comment.