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,
"host": "0.0.0.0",
"port": 9000,
"theme": "themes/example.css",
"public": true

View File

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

View File

@ -26,15 +26,16 @@ var inputs = [
"whois"
];
module.exports = function(port, isPublic) {
module.exports = function(port, host, isPublic) {
config.port = port;
config.host = host;
config.public = isPublic;
var app = http()
.use(index)
.use(http.static("client"))
.use(http.static(process.env.HOME + "/.shout/cache"))
.listen(config.port);
.listen(config.port, config.host);
sockets = io(app);
sockets.on("connect", function(socket) {
@ -46,7 +47,7 @@ module.exports = function(port, isPublic) {
});
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("");