From e0b6d7f17538d75c0b66416aee3ff91bb493c768 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 16 Sep 2013 19:27:03 +0200 Subject: [PATCH] [MISC] Add nice output about listening url. --- app.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 85d778e..e3e6620 100644 --- a/app.js +++ b/app.js @@ -84,13 +84,27 @@ app.use(function(err, req, res, next) { res.end(); }); +//define listening callback function +var onListenCallback = function() { + var url = ""; + url += (settings.general.https) ? "https://" : "http://"; + url += settings.general.listen.host; + if((settings.general.https && settings.general.listen.port != 443) || (!settings.general.https && settings.general.listen.port != 80)) { + url += ":"; + url += settings.general.listen.port; + } + url += "/"; + console.log("Dashboard now listening on: " + url); + console.log("Enjoy! ;-)"); +} + //fire it up as https (or http - NOT recommended(!)) server if(settings.general.https == true) { var httpsOptions = { "cert": fs.readFileSync(settings.https.cert), "key": fs.readFileSync(settings.https.key) }; - https.createServer(httpsOptions, app).listen(settings.general.listen.port, settings.general.listen.host); + https.createServer(httpsOptions, app).listen(settings.general.listen.port, settings.general.listen.host, onListenCallback); } else { - http.createServer(app).listen(settings.general.listen.port, settings.general.listen.host); -} \ No newline at end of file + http.createServer(app).listen(settings.general.listen.port, settings.general.listen.host, onListenCallback); +}