Skip to content

Commit

Permalink
[feature] Support for configuration file './config.json'
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhbrook committed Oct 28, 2011
1 parent cd3ba41 commit c571df5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bin/http-server
@@ -1,8 +1,21 @@
#!/usr/bin/env node

var HTTPServer = require('../lib/http-server').HTTPServer;
var HTTPServer = require('../lib/http-server').HTTPServer,
fs = require('fs'),
path = require('path'),
config = null;

var httpServer = new HTTPServer();
if (path.existsSync("./config.json")) {
console.log("Found configuration file ".green + "`./config.json`".cyan);

try {
config = JSON.parse(fs.readFileSync("./config.json").toString())
} catch (e) {
console.log("Error parsing ".red +"`./config.json`: ".cyan+("\""+e.message+"\"") + "; Ignoring.".yellow);
}
}

var httpServer = new HTTPServer(config);

httpServer.start();

Expand Down
4 changes: 4 additions & 0 deletions config.json
@@ -0,0 +1,4 @@
{
"root": "./public",
"port": 8080
}

0 comments on commit c571df5

Please sign in to comment.