X-Git-Url: http://git.pjr.cc/?p=nodejs-repoproxy.git;a=blobdiff_plain;f=lib%2Fmaintain.js;fp=lib%2Fmaintain.js;h=e336d4ad96a04792f5a6cf3a9d39b0f133742e4f;hp=0000000000000000000000000000000000000000;hb=04f3190a0bcc430af31917456a957ecc80eb160b;hpb=43d51752ca1aafe7212ee3805ba1b33e398c91ce diff --git a/lib/maintain.js b/lib/maintain.js new file mode 100644 index 0000000..e336d4a --- /dev/null +++ b/lib/maintain.js @@ -0,0 +1,38 @@ +var fs = require("fs"); +var http = require("http"); +var url = require("url"); +var path = require("path"); +var repoapt = require("./repo-apt.js"); +var repoyum = require("./repo-yum.js"); + +function maintainCache() { + // TODO i should check that im already running here and exit if i am + console.log("Cache maintainence routine starting..."); + for(var index in global.repoproxy.repo) { + console.log("start cleanup in ", index); + console.log("cleanup array ", global.repoproxy.repo[index]); + switch(global.repoproxy.repo[index]["type"]) { + case "apt": + console.log("Scanning '%s' as apt", index); + repoapt.maintain(global.repoproxy.repo[index]); + break; + case "yum": + console.log("Scanning '%s' as apt", index); + repoyum.maintain(global.repoproxy.repo[index]); + break; + } + } + console.log("Cache maintainence routine ended..."); +} + +exports.startTimer = function() { + // our once-a-day cache maintainer + var cacheTimer = global.repoproxy.scancache*3600*1000; + //var cacheTimer = global.repoproxy.scancache*100; + maintainCache(); + setInterval(maintainCache, cacheTimer); +} + +function cleanupRoutine() { + +} \ No newline at end of file