serverrunner v0.8.0
serverrunner
serverrunner starts node servers and then keeps them running. Allows for graceful shutdowns.
Installation
npm install serverrunnerUsage
var serverrunner = require('serverrunner');In the simplest case, serverrunner can be called with an options parameter with the following properties:
serverrunner({
workers: 4,
port: 80,
server: "../server/app.js",
watch: "../",
disgraceful: false,
allowForcedExit: false,
app: {
// Application config
}
});workersThe number of worker processes to create. A reasonable value is the number of processor cores on the server.portThe starting port number for worker processes to listen in on. Each subsequent worker will listen on the next port number. eg: ifworkersis set to 4 andportis set to 80, then the 4 workers will listen on 80, 81, 82, and 83 respectively.serverThe path to the file which will ultimately be require()'d by the worker processes. The path should be relative to the current working directory of the entry script. An absolute path works too. This file is expected to export a function that accepts a config parameter (the contents ofapp) and should return an express object.watchThis path will be watched for file changes and will trigger a server restart.disgracefulHelpful during development so that the server can be restarted or shut down instantly.allowForcedExitWaits for open connections to finish before shutting down or restarting but gives the option not to wait.appConfig options that will be passed to the app server.
Another way to use serverrunner is to pass a path to a .cjson file which contains a config as given above.
serverrunner('config/development.cjson');