Skip to content

Commit 71097ae

Browse files
committed
Move success message to app's listen callback.
express's `server.listen` has an asynchronous nature and it's API enables providing a callback that is fired upon success. Now the success messaage is logged only when the server has been set up and listening on provided socket address, otherwise the error stack trace is printed.
1 parent a7894d3 commit 71097ae

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

nodejs-role/app/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ app.get('/', function(req, res){
1111
});
1212

1313
// Listen on port 80 (like a true web server).
14-
app.listen(80);
15-
console.log('Express server started successfully.');
14+
app.listen(80, () => console.log('Express server started successfully.'));

nodejs/provisioning/app/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ app.get('/', function(req, res){
1111
});
1212

1313
// Listen on port 80 (like a true web server).
14-
app.listen(80);
15-
console.log('Express server started successfully.');
14+
app.listen(80, () => console.log('Express server started successfully.'));

0 commit comments

Comments
 (0)