Clean up server options

This commit is contained in:
Mattias Erming 2014-10-11 14:35:28 +02:00
parent 9cc793ef9e
commit d1296abf12
2 changed files with 16 additions and 14 deletions

View File

@ -1,3 +1,4 @@
var _ = require("lodash");
var ClientManager = new require("../clientManager");
var program = require("commander");
var shout = require("../server");
@ -5,7 +6,7 @@ var Helper = require("../helper");
program
.option("-H, --host <ip>" , "host")
.option("-p, --port <port>", "port")
.option("-P, --port <port>" , "port")
.option("-B, --bind <ip>" , "bind")
.option(" --public" , "mode")
.option(" --private" , "mode")
@ -26,9 +27,11 @@ program
console.log("Create a new user with 'shout add <name>'.");
console.log("");
} else {
var host = program.host || process.env.IP || config.host;
var port = program.port || process.env.PORT || config.port;
var bind = program.bind || process.env.BIND || config.bind;
shout(port, host, mode, bind);
shout({
host: program.host || config.host,
port: program.port || config.port,
bind: program.bind || config.bind,
public: mode
});
}
});

View File

@ -11,12 +11,9 @@ var config = {};
var sockets = null;
var manager = new ClientManager();
module.exports = function(port, host, isPublic, localIp) {
module.exports = function(options) {
config = Helper.getConfig();
config.port = port;
config.host = host;
config.public = isPublic;
config.bind = localIp;
config = _.extend(config, options);
var app = express()
.use(index)
@ -25,6 +22,8 @@ module.exports = function(port, host, isPublic, localIp) {
var server = null;
var https = config.https || {};
var protocol = https.enable ? "https" : "http";
var port = config.port;
var host = config.host;
if (!https.enable){
server = require("http");