Permalink
Browse files

wait for the app to actually listen before calling address()

  • Loading branch information...
1 parent 76f900b commit e5e1ecbad484a94a7127e0096d6a19d9116a6a94 @lornajane lornajane committed Sep 16, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 app.js
View
6 app.js
@@ -699,6 +699,8 @@ app.get('/:api([^\.]+)', function(req, res) {
if (!module.parent) {
var port = process.env.PORT || config.port;
- app.listen(port);
- console.log("Express server listening on port %d", app.address().port);
+ var l = app.listen(port);
+ l.on('listening', function(err) {
+ console.log("Express server listening on port %d", app.address().port);
+ });
}

0 comments on commit e5e1ecb

Please sign in to comment.