Skip to content

Commit c3fe93a

Browse files
committed
[fix] Update forever.startServer() to support more liberal arguments
1 parent fa3b225 commit c3fe93a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/forever.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,24 @@ forever.startDaemon = function (script, options) {
237237
// **NOTE:** This will change your `process.title`.
238238
//
239239
forever.startServer = function () {
240-
var monitors = Array.prototype.slice.call(arguments),
241-
callback = typeof monitors[monitors.length - 1] == 'function' && monitors.pop(),
240+
var args = Array.prototype.slice.call(arguments),
242241
socket = path.join(forever.config.get('sockPath'), 'forever.sock'),
242+
monitors = [],
243+
callback,
243244
server;
244-
245+
246+
args.forEach(function (a) {
247+
if (Array.isArray(a)) {
248+
monitors = monitors.concat(a.filter(function (m) { return m instanceof forever.Monitor }));
249+
}
250+
else if (a instanceof forever.Monitor) {
251+
monitors.push(a);
252+
}
253+
else if (typeof a === 'function') {
254+
callback = a;
255+
}
256+
});
257+
245258
server = net.createServer(function (socket) {
246259
//
247260
// Write the specified data and close the socket

0 commit comments

Comments
 (0)