Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (45 sloc) 2.29 KB

Multiple node server instance manager with Unicorn-like features

Heavily inspired by Spark and Unicorn

Why does fugue exist?


  • Supports any type of Node.js server as long as it inherits from net.Server (http.Server, connect.Server, ...).
  • Resuscitation - when a worker dies it is restarted.
  • Zero downtime app reload.
  • Set gid, uid.
  • Set working dir.
  • Redirect stdout to log files for master / workers
  • daemonize properly.
  • workers suicide after master sudden death.


npm install fugue



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

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

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

Having trouble? read the FAQ.


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:

  • started : callback to be invoked when all workers are up and running
  • working_path : absolute path for the working dir
  • tmp_path : the absolute path for the temp dir. defaults to '/tmp'
  • log_file : the full path of the log file if you wish stdout to be redirected there. All workers + master will write here. If absent does not touch stdout
  • master_log_file : alternative path for the log file for the master only
  • uid : unix user id for workers. Defaults to current user
  • gid : unix group id for workers. Defaults to current group
  • daemonize : to fork and detach
  • master_pid_path : master PID file path. If not passed in, no pid file is written
  • worker_to_master_ping_interval : the interval by which children ping master to know if it's alive. in milliseconds. defaults to 30000 (30 seconds)

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.

Read more on how this works.

Jump to Line
Something went wrong with that request. Please try again.