diff --git a/lib/forever.js b/lib/forever.js index b0171f1a..d7a23760 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -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