Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eknkc/usta
Worker process coordinator for Node.JS clusters
https://github.com/eknkc/usta
Last synced: about 2 months ago
JSON representation
Worker process coordinator for Node.JS clusters
- Host: GitHub
- URL: https://github.com/eknkc/usta
- Owner: eknkc
- Created: 2013-09-19T22:03:57.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-22T00:26:52.000Z (about 11 years ago)
- Last Synced: 2024-09-19T00:15:56.161Z (4 months ago)
- Language: JavaScript
- Size: 136 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# usta
Worker process coordinator for Node.JS clusters. It used the built in `cluster` module to fire up multiple node processes and coordinates the work between them.##install
npm install usta
##usage
usta has 2 different interfaces, one for the master process and one for the worker processes. The basic idea is to have multiple pools of processes. One can define a pool for web server that contains 4 child processes, a single process for background jobs and 2 more for work queue consumers easily.###master
var usta = require('usta');
if (usta.isMaster) {
// Necessary
// Setup the cluster master
usta.setup({
silent: false, // Suppress child process output, default false
exec: __filename, // The entry point for workers, if not specified, current file is used
logger: function(log) {…} // A function to intercept logs. Defaults to stdout.
});// Create a new worker pool
// poolname is required, all config vars are optional, default values are listed below.
// usta.pool(poolname, options)
usta.pool('web', {
ttl: 0, // Time in ms to recycle processes. Children will be restarted in this period.
size: 0, // Number of child processes required for this pool
args: {}, // Custom arguments to be sent to children
env: {}, // Custom environment variables
strict: false, // If true, pool does not have more than size processes in any case
killDelay: 60000, // Wait time in ms to forcefully kill a process that does not gracefully exit
restartDelay: 2000 // Wait time in ms for consecutive restarts
});// Create another pool
usta.pool('crons', {
…
});
}## worker
var usta = require('usta');
if (!usta.isMaster) {
// All workers are created equal, therefore it is required to distinguish pools here.
// Register a function to be called for web workers
usta.register("web", function() {
// do whatever you wish
});// Register another type of worker
usta.register("crons", function() {
// do whatever you wish
});
}##license
MIT