Created
November 18, 2013 13:43
-
-
Save twilson63/7527961 to your computer and use it in GitHub Desktop.
Replicate Npm Registry Monitor script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx for this one :D