Skip to content

Instantly share code, notes, and snippets.

@twilson63
Created November 18, 2013 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twilson63/7527961 to your computer and use it in GitHub Desktop.
Save twilson63/7527961 to your computer and use it in GitHub Desktop.
Replicate Npm Registry Monitor script
var nano = require('nano')('http://localhost:5984');
function checkTasks(cb) {
nano.request({ path: '_active_tasks'}, cb);
}
function replicateNpm(cb) {
nano.db.replicate('http://isaacs.iriscouch.com/registry', 'registry',
{ continuous: true,
worker_processes: 10,
http_connections: 60}, cb);
}
function renewReplication(cb) {
checkTasks(function(e,b) {
if (e) { return cb(e); }
if (b.length > 0) { return cb(null, b); }
replicateNpm(cb);
});
}
function main() {
renewReplication(function(e,b) {
if (e) { return console.log(e); }
console.log(b);
setTimeout(main, 60000);
});
}
main();
@ZeroDragon
Copy link

Thx for this one :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment