[MISC] Add nice output about listening url.

This commit is contained in:
Jan Philipp Timme 2013-09-16 19:27:03 +02:00
parent 3d1b6369a2
commit e0b6d7f175

18
app.js
View File

@ -84,13 +84,27 @@ app.use(function(err, req, res, next) {
res.end(); 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 //fire it up as https (or http - NOT recommended(!)) server
if(settings.general.https == true) { if(settings.general.https == true) {
var httpsOptions = { var httpsOptions = {
"cert": fs.readFileSync(settings.https.cert), "cert": fs.readFileSync(settings.https.cert),
"key": fs.readFileSync(settings.https.key) "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 { } else {
http.createServer(app).listen(settings.general.listen.port, settings.general.listen.host); http.createServer(app).listen(settings.general.listen.port, settings.general.listen.host, onListenCallback);
} }