adding a debug library
authorPaul J R <me@pjr.cc>
Tue, 25 Jun 2013 22:07:45 +0000 (08:07 +1000)
committerPaul J R <me@pjr.cc>
Tue, 25 Jun 2013 22:07:45 +0000 (08:07 +1000)
lib/cache.js
lib/debug.js [new file with mode: 0644]
lib/repo-yum.js
proxy.js
repos.conf

index 4f98d3c..464c1b3 100644 (file)
@@ -103,10 +103,8 @@ function getAndService(unify, xpath, filesize) {
        log.debug("calling in here with filesize, ", filesize)
        unify.b.writeHead(200, {'Content-Length' : filesize});
 
-       
        global.repoproxy.downloads[unify.fullFilePath] = 1;
        
-
        http.get(xpath, function(res) {
 
            var file = fs.createWriteStream(unify.fullFilePath);
@@ -193,7 +191,8 @@ function inlineService(unify) {
                                                }
                                        }
                                } else {
-                                       log.debug("inline service - we're in a very bad place");
+                                       log.error("inline service - we're in a very bad place, how we ended up here we dont know, but we need to crash");
+                                       process.exit(10);
                                }
                        });
                        
diff --git a/lib/debug.js b/lib/debug.js
new file mode 100644 (file)
index 0000000..5a6cc8a
--- /dev/null
@@ -0,0 +1,17 @@
+var log = require("./log.js");
+
+function startDebugTimer() {
+       if(typeof global.repoproxy != "undefined") {
+               if(global.repoproxy.loglevel >= 5) {
+                       log.debug("starting debug timer on loglevel");
+                       setInterval(debugTimer, 1500);
+               }
+       }
+}
+
+function debugTimer() {
+       log.debug("globals: ", global.repoproxy);
+       log.debug("*****TICK******");
+}
+
+exports.startDebugTimer = startDebugTimer;
\ No newline at end of file
index 4de23b9..98061c9 100644 (file)
@@ -35,8 +35,7 @@ function maintain(name, repoinfo, files) {
                                
                                var age = curtime - ctime;
                                log.debug("age is (%d) for (%d)", age, metaAge);
-                               if(age < metaAge) {
-                                       // TODO: cleanup repomd directory
+                               if(age > metaAge) {
                                        cache.moveToCleanup(repomddir);
                                        log.info("Sending repomd directory to trash for cleanup (%s)", repomddir);
                                }
@@ -72,7 +71,6 @@ function maintain(name, repoinfo, files) {
        if(typeof files[0] != 'undefined') fileCheck(0)
        else log.info("Skipping (yum) file check as there are none... apprently?");
 
-
 }
 
 exports.maintain = maintain;
\ No newline at end of file
index da86761..bbb75ce 100644 (file)
--- a/proxy.js
+++ b/proxy.js
@@ -4,6 +4,7 @@ var router = require("./lib/router.js");
 var cache = require("./lib/cache.js");
 var maintain = require("./lib/maintain.js");
 var log = require("./lib/log.js");
+var debug = require("./lib/debug.js");
 
 
 // first we load the config...
@@ -14,5 +15,8 @@ config.loadConfig("./repos.conf");
 log.info("Starting cache maintenance timer");
 maintain.startTimer();
 
+// start the debug timer, if we should
+debug.startDebugTimer();
+
 // next we start our main request loop
 http.createServer(router.routeRequest).listen(global.repoproxy.listenPort);
index e9e9042..80b4d39 100644 (file)
@@ -19,5 +19,5 @@ listenport:8008
 repo:fedora:yum:http://ftp.iinet.net.au/pub/fedora/linux/:7:120
 repo:ubuntu:apt:http://ftp.iinet.net.au/pub/ubuntu/:1:120
 
-# level for logging (1 = error, 2 = warning, 3=info, 4=debug);
+# level for logging (1 = error, 2 = warning, 3=info, 4=debug, 5=debug with timer);
 loggerlevel:4