Added listen IP parameter. Listening on localhost allow to put Nginx/Varnish in front of shout server

This commit is contained in:
Jonathan Huot 2014-09-09 09:48:53 +02:00
parent 2f5be12d00
commit 3a093dacd8
3 changed files with 8 additions and 4 deletions

View file

@ -1,5 +1,6 @@
{ {
"debug": false, "debug": false,
"host": "0.0.0.0",
"port": 9000, "port": 9000,
"theme": "themes/example.css", "theme": "themes/example.css",
"public": true "public": true

View file

@ -4,6 +4,7 @@ var program = require("commander");
var shout = require("../server"); var shout = require("../server");
program program
.option("-h, --host <ip>")
.option("-p, --port <port>") .option("-p, --port <port>")
.command("start") .command("start")
.description("Start the server") .description("Start the server")
@ -15,7 +16,8 @@ program
console.log("Create a new user with 'shout add <name>'.") console.log("Create a new user with 'shout add <name>'.")
console.log(""); console.log("");
} else { } else {
var host = program.host || config.host;
var port = program.port || config.port; var port = program.port || config.port;
shout(port, config.public); shout(port, host, config.public);
} }
}); });

View file

@ -26,15 +26,16 @@ var inputs = [
"whois" "whois"
]; ];
module.exports = function(port, isPublic) { module.exports = function(port, host, isPublic) {
config.port = port; config.port = port;
config.host = host;
config.public = isPublic; config.public = isPublic;
var app = http() var app = http()
.use(index) .use(index)
.use(http.static("client")) .use(http.static("client"))
.use(http.static(process.env.HOME + "/.shout/cache")) .use(http.static(process.env.HOME + "/.shout/cache"))
.listen(config.port); .listen(config.port, config.host);
sockets = io(app); sockets = io(app);
sockets.on("connect", function(socket) { sockets.on("connect", function(socket) {
@ -46,7 +47,7 @@ module.exports = function(port, isPublic) {
}); });
console.log(""); console.log("");
console.log("Shout is now running on port " + config.port); console.log("Shout is now running on host/port " + config.host + ":" + config.port);
console.log("Press ctrl-c to stop"); console.log("Press ctrl-c to stop");
console.log(""); console.log("");