Skip to content

Instantly share code, notes, and snippets.

@marshallswain
Created December 29, 2013 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallswain/8166198 to your computer and use it in GitHub Desktop.
Save marshallswain/8166198 to your computer and use it in GitHub Desktop.
Deployd custom start script and forever-monitor examples Install Deployd locally using npm install deployd --save. Then npm install forever-monitor --save.
var forever = require('forever-monitor');
var child = new (forever.Monitor)('server.js', {
max: 10,
silent: true,
options: []
});
child.on('exit', function () {
console.log('Your server has exited after 3 restarts');
});
child.start();
// production.js
var deployd = require('deployd');
var server = deployd({
port: process.env.PORT || 3000, // or whatever port you want.
env: 'development',
db: {
host: 'server.mongohq.com',
port: 10016,
name: 'DBNAME',
credentials: {
username: '',
password: ''
}
}
});
server.listen();
server.on('listening', function() {
console.log("Server is listening");
});
server.on('error', function(err) {
console.error(err);
process.nextTick(function() { // Give the server a chance to return an error
process.exit();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment