git2consul
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -60,3 +60,3 @@ var fs = require('fs'); | ||
if (errs) return cb(errs); | ||
if (errs.length > 0) return cb(errs); | ||
} | ||
@@ -70,2 +70,6 @@ | ||
GitManager.prototype.getRepoName = function() { | ||
return config.name; | ||
}; | ||
GitManager.prototype.getBranchNames = function() { | ||
@@ -97,2 +101,4 @@ return config.branches; | ||
exports.createGitManager(repo_config, function(err, git_manager) { | ||
if (err) console.error('Got error %s', err); | ||
if (err) errors.push(err); | ||
@@ -99,0 +105,0 @@ else git_managers.push(git_manager); |
@@ -9,2 +9,24 @@ | ||
// TODO: Validate config. | ||
var start_branch_updater = function(bm) { | ||
console.log('Polling branch %s of repo %s', bm.getBranchName(), git_manager.getRepoName()); | ||
setInterval(function() { | ||
bm.handleRefChange(null, function(err) { | ||
if (err) console.error(err); | ||
console.log('Updates in branch %s complete', bm.getBranchName()); | ||
}); | ||
}, config.interval * 60 * 1000); | ||
}; | ||
git_manager.getBranchNames().forEach(function(branch) { | ||
var bm = git_manager.getBranchManager(branch); | ||
setTimeout(function() { | ||
start_branch_updater(bm); | ||
// Start the branch updater some random number of seconds from 1 to 30. This is just to space | ||
// out the updates and reduce load. | ||
}, ((Math.floor((Math.random() * 30) + 1) ) * 1000)); | ||
}); | ||
console.log('Polling hook initialized with %s minute intervals', config.interval); | ||
}; |
{ | ||
"name": "git2consul", | ||
"description": "System for moving data from git to consul", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"contributors": [ | ||
@@ -6,0 +6,0 @@ { |
@@ -7,3 +7,3 @@ #### git2consul | ||
git2consul will be added to NPM shortly. For now, installation requires that you clone the repo and run `npm install` from the git2consul directory. | ||
`npm install git2consul` | ||
@@ -10,0 +10,0 @@ ##### Requirements / Caveats |
@@ -7,21 +7,2 @@ var fs = require('fs'); | ||
if (process.argv.length === 3) { | ||
var config_file = process.argv[2]; | ||
console.log('Adding %s as consul config', config_file); | ||
var config = fs.readFileSync(config_file, {'encoding':'utf8'}); | ||
try { | ||
JSON.parse(config); | ||
} catch(e) { | ||
console.error('config_file is not valid JSON'); | ||
process.exit(1); | ||
} | ||
exports.setConfig(config, function(err) { | ||
if (err) return console.error("Failed to write config"); | ||
}); | ||
} | ||
/** | ||
@@ -49,1 +30,20 @@ * This utility adds keys from the top level of a .json config file to the /git2consul/ path of | ||
} | ||
if (process.argv.length === 3) { | ||
var config_file = process.argv[2]; | ||
console.log('Adding %s as consul config', config_file); | ||
var config = fs.readFileSync(config_file, {'encoding':'utf8'}); | ||
try { | ||
JSON.parse(config); | ||
} catch(e) { | ||
console.error('config_file is not valid JSON'); | ||
process.exit(1); | ||
} | ||
exports.setConfig(config, function(err) { | ||
if (err) return console.error("Failed to write config"); | ||
}); | ||
} |
333411
884