From 65507807acfe25da6b2db379cd72b01e3b304e62 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 23 Oct 2017 13:03:10 -0400 Subject: [PATCH] Ask Node's `net.server` for the actual address its listening on This allows us to emit a helpful and correct message when Pelias starts. --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index baefb894..f541c0cc 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,8 @@ const app = require('./app'), port = ( process.env.PORT || 3100 ), host = ( process.env.HOST || undefined ); -/** run server on the default setup (single core) **/ -console.log( `pelias is now running on ${host}:${port}` ); -app.listen( port, host ); +const server = app.listen( port, host, () => { + // ask server for the actual address and port its listening on + const listenAddress = server.address(); + console.log( `pelias is now running on ${listenAddress.address}:${listenAddress.port}` ); +});