From e03ba0bc17312d19afba035295d9b10049b10cb7 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Wed, 26 Jun 2013 08:07:45 +1000 Subject: [PATCH] adding a debug library --- lib/cache.js | 5 ++--- lib/debug.js | 17 +++++++++++++++++ lib/repo-yum.js | 4 +--- proxy.js | 4 ++++ repos.conf | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 lib/debug.js diff --git a/lib/cache.js b/lib/cache.js index 4f98d3c..464c1b3 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -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 index 0000000..5a6cc8a --- /dev/null +++ b/lib/debug.js @@ -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 diff --git a/lib/repo-yum.js b/lib/repo-yum.js index 4de23b9..98061c9 100644 --- a/lib/repo-yum.js +++ b/lib/repo-yum.js @@ -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 diff --git a/proxy.js b/proxy.js index da86761..bbb75ce 100644 --- 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); diff --git a/repos.conf b/repos.conf index e9e9042..80b4d39 100644 --- a/repos.conf +++ b/repos.conf @@ -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 -- 1.7.0.4