Skip to content

Commit

Permalink
Adding console log on sandbox server startup (#2210)
Browse files Browse the repository at this point in the history
* Adding console log on sandbox server startup

* Update server.js

Add server error handeling

* Update server.js

Better error message, remove retry.

Co-authored-by: Philippe Recto <precto1285@gmal.com>
Co-authored-by: Felipe Martins <felipewmartins@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
  • Loading branch information
4 people committed May 29, 2020
1 parent ee46dff commit 0077205
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sandbox/server.js
Expand Up @@ -54,8 +54,8 @@ server = http.createServer(function (req, res) {
console.error('Error:', e.message);
status = 400;
result = {
error: e.message
};
error: e.message
};
}

res.writeHead(status, {
Expand All @@ -69,4 +69,12 @@ server = http.createServer(function (req, res) {
}
});

server.listen(3000);
const PORT = 3000;

server.listen(PORT, console.log(`Listening on localhost:${PORT}...`));
server.on('error', (error) => {
if (error.code === 'EADDRINUSE') {
console.log(`Address localhost:${PORT} in use please retry when the port is available!`);
server.close();
}
});

0 comments on commit 0077205

Please sign in to comment.