Skip to content

Commit

Permalink
Add optional external configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
danmactough committed Mar 4, 2012
1 parent 7b2ebc6 commit 94d031e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
14 changes: 14 additions & 0 deletions config-sample.js
@@ -0,0 +1,14 @@
/*!
* node-parserproxy - Config sample
* Copyright(c) 2011 Dan MacTough <danmactough@gmail.com>
* All rights reserved.
*/

/**
* Parserproxy configuration.
*/

exports = module.exports = {
port : 3010
, timeout : null // Takes a Number
}
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "parserproxy",
"author": "Dan MacTough <danmactough@gmail.com>",
"description": "A JSON-over-HTTP proxy for node-feedparser and node-opmlparser",
"version": "0.1.4",
"version": "0.1.5",
"repository": {
"type": "git",
"url": "git://github.com/danmactough/node-parserproxy.git"
Expand All @@ -19,4 +19,3 @@
},
"devDependencies": {}
}

9 changes: 7 additions & 2 deletions server.js
Expand Up @@ -16,8 +16,13 @@ var http = require('http')

if (!module.parent) {

var port = process.env['PARSER_PROXY_PORT'] || 3030
, timeout = process.env['PARSER_PROXY_TIMEOUT'] || 3000;
var config = {};
try {
config = require('./config');
} catch(e) { };

var port = process.env['PARSER_PROXY_PORT'] || config.port || 3030
, timeout = process.env['PARSER_PROXY_TIMEOUT'] || config.timeout || 3000;

process.on('uncaughtException', function (err) {
console.error('Caught exception: ' + err);
Expand Down

0 comments on commit 94d031e

Please sign in to comment.