Zion is a nodejs process supervisor. It uses the cluster module that has been added to node 0.6.0 to fork child workers. Each child will load the given package and call the main entry function.

The master maintains a two-way communication channel with its children. This allows child processes to send messages to the master, for example to instruct the master to fork or restart workers. The main motivation for that was to create self-updating web servers: Add a special route to your web app (eg. POST /site/deploy), in the handler update the source code (eg. git pull && make) and finally send a message to the master to restart all workers.

The package is required to export a function which will be called by the worker and given a single argument. After startup the master will create a single worker and send it a 'zion:bootstrap' message. Use that to bootstrap your application (forking any workers that are necessary). Here is an example main entry function:

module.exports = function(msg) {
    if (msg.cmd === 'zion:bootstrap') {
        process.send({ cmd: 'zion:fork', worker: 'express-http-server' })
        process.send({ cmd: 'zion:fork', worker: 'background-job-handler' })

    } else if (msg.cmd === 'zion:fork') {
        require(__dirname + '/workers/' + msg.worker)

If a worker exits with exit code other than 0, it is immediately restarted. If the exit code is 0 then the worker is discarded and never started again.

Usage: zion /path/to/package