Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #954 from caridy/nodejitsu
Browse files Browse the repository at this point in the history
Fix for app failures when deploying to nodejitsu.
  • Loading branch information
caridy committed Jan 26, 2013
2 parents 1a9f980 + 3fa49e1 commit 1e6b4bb
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions lib/mojito.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,18 +489,22 @@ MojitoServer.prototype.getHttpServer = function() {
* Begin listening for inbound connections.
* @param {Number} port The port number. Defaults to the server's value for
* options.port (which defaults to process.env.PORT followed by 8666).
* @param {String} host The hostname or IP address in string form.
* @param {String} host Optional hostname or IP address in string form.
* @param {Function} callback Optional callback to get notified when the
* server is ready to server traffic.
*/
MojitoServer.prototype.listen = function(port, host, cb) {
MojitoServer.prototype.listen = function(port, host, callback) {

var logger,
app = this._app,
p = port || this._options.port,
h = host || this._options.host,
callback = cb || Mojito.NOOP,
handler = function(err) {
callback(err, app);
};
if (callback) {
callback(err, app);
}
},
listenArgs = [p];

// Track startup time and use it to ensure we don't try to listen() twice.
if (this._startupTime) {
Expand All @@ -515,14 +519,17 @@ MojitoServer.prototype.listen = function(port, host, cb) {
libutils.warn('Starting Mojito Application');
}

if (h) {
listenArgs.push(h);
}
if (callback) {
listenArgs.push(handler);
}

try {
if (h) {
app.listen(p, h, handler);
} else {
app.listen(p, handler);
}
app.listen.apply(app, listenArgs);
} catch (err) {
callback(err);
handler(err);
}
};

Expand Down

0 comments on commit 1e6b4bb

Please sign in to comment.