Skip to content

Commit

Permalink
[fix] Update forever.startServer() to support more liberal arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Aug 12, 2011
1 parent fa3b225 commit c3fe93a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,24 @@ forever.startDaemon = function (script, options) {
// **NOTE:** This will change your `process.title`.
//
forever.startServer = function () {
var monitors = Array.prototype.slice.call(arguments),
callback = typeof monitors[monitors.length - 1] == 'function' && monitors.pop(),
var args = Array.prototype.slice.call(arguments),
socket = path.join(forever.config.get('sockPath'), 'forever.sock'),
monitors = [],
callback,
server;


args.forEach(function (a) {
if (Array.isArray(a)) {
monitors = monitors.concat(a.filter(function (m) { return m instanceof forever.Monitor }));
}
else if (a instanceof forever.Monitor) {
monitors.push(a);
}
else if (typeof a === 'function') {
callback = a;
}
});

server = net.createServer(function (socket) {
//
// Write the specified data and close the socket
Expand Down

0 comments on commit c3fe93a

Please sign in to comment.