Use PORT and IP environment variables

This makes Shout Heroku / Dokku / Plusku compatible.
This commit is contained in:
Stuart P. Bentley 2014-09-09 04:12:23 -07:00
parent 273e3acf13
commit 3cfa1f42b2

View File

@ -1,23 +1,23 @@
var config = require("../../config.json"); var config = require("../../config.json");
var ClientManager = new require("../clientManager"); var ClientManager = new require("../clientManager");
var program = require("commander"); var program = require("commander");
var shout = require("../server"); var shout = require("../server");
program program
.option("-h, --host <ip>") .option("-h, --host <ip>")
.option("-p, --port <port>") .option("-p, --port <port>")
.command("start") .command("start")
.description("Start the server") .description("Start the server")
.action(function() { .action(function() {
var users = new ClientManager().getUsers(); var users = new ClientManager().getUsers();
if (!config.public && !users.length) { if (!config.public && !users.length) {
console.log(""); console.log("");
console.log("No users found!"); console.log("No users found!");
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 host = program.host || process.env.IP || config.host;
var port = program.port || config.port; var port = program.port || process.env.PORT || config.port;
shout(port, host, config.public); shout(port, host, config.public);
} }
}); });