Created
August 12, 2011 03:22
-
-
Save indexzero/1141361 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'), | |
forever = require('forever'); | |
function startApp (options, next){ | |
var child = new (forever.Monitor) (script, { | |
'options': [ | |
'--port', options.port, | |
'--secret', options.secret, | |
'--userSchema', options.userSchema | |
] | |
}); | |
child.start(); | |
child.on('start', function (_, data) { | |
console.log('Forever process running server.js on ' + options.port); | |
next(null, child); | |
}); | |
} | |
// Array config data | |
var apps = [ | |
{ userSchema: 'test1', port: 8000, secret: 'krFB6so8GZdJCqfcu9oh' }, | |
{ userSchema: 'test2', port: 8001, secret: 'xIXQw2RfmFqNTwlhmQmw' } | |
] | |
async.map(apps, startApp, function (err, monitors) { | |
forever.startServer(monitors, function () { | |
// | |
// Ignore data returned from `.startServer()` | |
// | |
}); | |
}); | |
// Calling during app.get | |
app.get('/servers', requiresLogin, function (req, res) { | |
forever.list(false, function (err, data) { | |
if (err) { | |
throw err; | |
} | |
console.log(data) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment