Skip to content

Commit

Permalink
passing CouchDB hostname via configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Kujawa committed Jan 1, 2014
1 parent ffde0b1 commit 84a24ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions conf.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
"workers": 2,
"seedUrl": "http://127.0.0.1:5984/_utils/docs/",
"database": {
"name": "web-crawler-example2",
"name": "example",
"host": "http://127.0.0.1:5984",
"rebuild": true
},
"jobs": [
{ "name": "logger" },
{ "name": "saver" },
{ "name": "driller",
"domainRestriction": "127.0.0.1"
"domainRestriction": "127.0.0.1",
"selector": "a"
},
{ "name": "scheduler" }
]
Expand Down
2 changes: 1 addition & 1 deletion webcrawler/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ agent._run = function( config ) {
var couchdb = require( './storage/couchdb' ),
self = this;

couchdb.init({ dbname: config.getDatabaseName() });
couchdb.init({ dbname: config.getDatabaseName(), host: config.getDatabaseHost() });

async.waterfall([
function(callback){
Expand Down
7 changes: 6 additions & 1 deletion webcrawler/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var exports = module.exports = Config;
function Config( options ) {
this.defaults = {
workers: 5,
databaseName: 'web-crawler'
databaseName: 'web-crawler',
databaseHost: 'http://127.0.0.1:5984'
};

this.options = options;
Expand All @@ -17,6 +18,10 @@ Config.prototype.getDatabaseName = function() {
return this.options.database.name == undefined ? this.defaults.databaseName : this.options.database.name;
}

Config.prototype.getDatabaseHost = function() {
return this.options.database.name == undefined ? this.defaults.databaseHost : this.options.database.host;
}

Config.prototype.getDatabaseRebuild = function() {
return this.options.database.rebuild == undefined ? false : this.options.database.rebuild;
}
Expand Down

0 comments on commit 84a24ee

Please sign in to comment.