urbane

Restart your app like a gentleman

npm install urbane
20 downloads in the last month

Installation

npm install -S urbane

Usage

Create a file called urbane.js (or cluster.js... or anything you want really). This will start your app as a cluster (assuming your application is in app.js).

require('urbane')();

Run your urbane file with any of the environment variables or flags you want passed to app.js.

PORT=8000 node urbane.js --use https

With Capistrano

If you use capistrano or something similar for deploying, make sure to set the appPath to your current directory so that deploys will be picked up.

require('urbane')({
  appPath : '/www/nodeapp/current/'
})

Restarting

To restart the app gracefully send it a USR2 signal.

kill -USR2 `cat tmp/pids/node.pid`

Or if you want to stop it gracefully.

kill -QUIT `cat tmp/pids/node.pid`

Options

Urbane accepts an object of options with the following nodes.

appFile
default: 'app.js'
The filename of the actual application.

appPath
default:''
This should be the root path that the appFile, pidFile, and logs all share in common. It should include the trailing slash.

autoKill
default: true
Tells urbane to automatically kill off the old process once the new one is started.

delay
default: 10
The amount of time (in seconds) to wait before replacing a crashed thread.

log
default: {stdout: 'log/urbane.out.log', stderr: 'log/urbane.err.log'}
The location that logs should be written to.

pidFile
default: 'tmp/pids/node.pid/
The location to write the master pid

workers
default: 4
The number of workers you want started up.

npm loves you