adding the cleanup routines
authorpaulr <paulr@tv.pjr.cc>
Mon, 21 Jan 2013 08:39:40 +0000 (19:39 +1100)
committerpaulr <paulr@tv.pjr.cc>
Mon, 21 Jan 2013 08:39:40 +0000 (19:39 +1100)
lib/cache.js
lib/maintain.js [new file with mode: 0644]
lib/repo-apt.js [new file with mode: 0644]
lib/repo-yum.js [new file with mode: 0644]
proxy.js

index 9e5e8da..b7f111d 100644 (file)
@@ -3,19 +3,6 @@ var http = require("http");
 var url = require("url");
 var path = require("path");
 
-function maintainCache() {
-       // TODO i should check that im already running here and exit if i am
-       console.log("Cache maintainence routine starting...");
-       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;
-       setInterval(maintainCache, cacheTimer);
-}
-
 function upstreamRequest(unify) {
        // first do a head request
        console.log("upsteram as ", unify.requestFor);
diff --git a/lib/maintain.js b/lib/maintain.js
new file mode 100644 (file)
index 0000000..e336d4a
--- /dev/null
@@ -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
diff --git a/lib/repo-apt.js b/lib/repo-apt.js
new file mode 100644 (file)
index 0000000..f37f881
--- /dev/null
@@ -0,0 +1,5 @@
+function maintain(details) {
+       console.log("doing apt clean for ", details);
+}
+
+exports.maintain = maintain;
\ No newline at end of file
diff --git a/lib/repo-yum.js b/lib/repo-yum.js
new file mode 100644 (file)
index 0000000..18b383a
--- /dev/null
@@ -0,0 +1,5 @@
+function maintain(details) {
+       console.log("doing yum clean for ", details);
+}
+
+exports.maintain = maintain;
\ No newline at end of file
index 65cf726..dabbdec 100644 (file)
--- a/proxy.js
+++ b/proxy.js
@@ -2,6 +2,7 @@ var http = require("http");
 var config = require("./lib/config.js");
 var router = require("./lib/router.js");
 var cache = require("./lib/cache.js");
+var maintain = require("./lib/maintain.js");
 
 
 // first we load the config...
@@ -10,7 +11,7 @@ config.loadConfig("./repos.conf");
 
 
 console.log("Starting cache maintenance timer");
-cache.startTimer();
+maintain.startTimer();
 
 // next we start our main request loop
 http.createServer(router.routeRequest).listen(global.repoproxy.listenPort);