pgte / fugue

Unicorn for node.js
MIT License
396 stars 14 forks source link

No longer supported!!!!

Multiple node server instance manager with Unicorn-like features

Heavily inspired by Spark and Unicorn

Why does fugue exist?

Fugue v0.1.0 Requires node.js v0.3.2 or superior.

Fugue v0.0.38 and below Requires node.js 0.v2.2 or superior.

Features:

Install:

npm install fugue

Usage:

Example:

var fugue = require('fugue'),
    net =   require('net');

var server = net.createServer(function(conn) {
  conn.end(process.pid.toString() + "Hello from worker " + fugue.workerId());
});

fugue.start(server, 4000, null, 2, {verbose : true});

Having trouble? read the FAQ.

fugue.start

For TCP:

fugue.start(server, port, host, number_of_workers, options);

For UNIX sockets:

fugue.start(server, socket_path, number_of_workers, options);

Options on fugue.start:

How to reload

You can reload the entire app (with no downtime) For now, you will have to find the PID of the master and, on the command line:

kill -USR2 <PID>

That will reload your service with no downtime.

Notice that the slaves will only die when all the TCP connections end or after 30 seconds. If you are using an HTTP server, a slave could be waiting on browser HTTP keep-alive connections. On development environments, you would have to kill the browser for the slave to die - (on development environments you shouldn't really use fugue).

Read more on how this works.

Other available functions:

fugue.stop()

Kills fugue workers and closes the server socket.

fugue.isWorker()

Returns true if current process is a worker process. Returns false if current process is master.

fugue.isMaster()

Returns true if current process is master. Returns false if current process is a worker process.

fugue.workerPids()

Returns an array of integers with the workers process IDs.

fugue.masterSocketPath()

This method is public mainly because of allowing some complicated tests to be possible. Apps should not care.