====
- fix the log.* entries that need to be errors
-- metadata check on maintenance routines
--
\ No newline at end of file
+- metadata check on maintenance routines
\ No newline at end of file
default:
if(line_real[0] != "") {
- log.info("WARNING Invalid line in configuration file ignored: '%s'", line_one);
+ log.warning("Invalid line in configuration file ignored: '%s'", line_one);
}
}
}
//var ts = ts_t.format("%Y-%m-%d %H:%M:%S");
arguments["0"] = "[??INFO??] ("+ts+"): "+orig;
- if(typeof global.repoproxy.loglevel == "undefined" || global.repoproxy.loglevel >= 3) {
+ if(typeof global.repoproxy == "undefined" || global.repoproxy.loglevel >= 3) {
sendLog.apply(this, arguments);
}
}
//var ts = ts_t.format("%Y-%m-%d %H:%M:%S");
arguments["0"] = "[^^DEBUG^^] ("+ts+"): "+orig;
- if(typeof global.repoproxy.loglevel != "undefined") {
- if(global.repoproxy.loglevel >= 3) {
+ if(typeof global.repoproxy != "undefined") {
+ if(global.repoproxy.loglevel >= 4) {
sendLog.apply(this, arguments);
}
}
//var ts = ts_t.format("%Y-%m-%d %H:%M:%S");
arguments["0"] = "[!!WARNING!!] ("+ts+"): "+orig;
- if(typeof global.repoproxy.loglevel == "undefined" || global.repoproxy.loglevel >= 2) {
+ if(typeof global.repoproxy == "undefined" || global.repoproxy.loglevel >= 2) {
sendLog.apply(this, arguments);
}
}
//var ts = ts_t.format("%Y-%m-%d %H:%M:%S");
arguments["0"] = "[**ERROR**] ("+ts+"): "+orig;
- if(typeof global.repoproxy.loglevel == "undefined" || global.repoproxy.loglevel >= 1) {
+ if(typeof global.repoproxy == "undefined" || global.repoproxy.loglevel >= 1) {
sendLog.apply(this, arguments);
}
}
function maintainCache() {
// TODO i should check that im already running here and exit if i am
- log.debug("Cache maintainence routine starting...");
+ if(global.repoproxy.maintain==1) {
+ log.warning("cache maintenance routine started, but its already running");
+ return;
+ }
+
+ global.repoproxy.maintain = 1;
+
+ log.info("Cache maintainence routine starting...");
for(var index in global.repoproxy.repo) {
//log.debug("start cleanup in ", index);
//log.debug("cleanup array ", global.repoproxy.repo[index]);
break;
}
}
- log.debug("Cache maintainence routine ended...");
+ log.info("Cache maintainence routine ended...");
+
+
+
+ log.info("beginning cache trash cleanup");
+ // TODO: do this bit properly, check that globals are set properly
+ var spawn = require('child_process').spawn;
+
+ // TODO: be carefull we actually have a place to remove
+ if(typeof global.repoproxy == "undefined") {
+ log.error("serious issue, globals not accessible?");
+ process.exit(10);
+ } else if(typeof global.repoproxy.cacheDir == "undefined") {
+ log.error("serious issue, globals not accessible (cache check)?");
+ process.exit(10);
+ } else {
+ var remove = spawn("rm", ["-r", global.repoproxy.cacheDir + "/.cleanup/*"]);
+ remove.on("close", function(code, sig) {
+ log.debug("remove ended with %d, %d", code, sig);
+ });
+ remove.stderr.on("data", function(line) {
+ log.debug("stderr from lazy remove: ", line.toString("utf8"));
+ });
+ remove.stdout.on("data", function(line) {
+ log.debug("stdout from lazy remove: ", line.toString("ascii"));
+ });
+ }
+ log.info("Trash empty");
+
+ global.repoproxy.maintain = 0;
}
exports.startTimer = function() {
var age = curtime - ctime;
log.debug("age is (%d) for (%d)", age, metaAge);
- if(age > metaAge) {
+ if(age < metaAge) {
// TODO: cleanup repomd directory
cache.moveToCleanup(repomddir);
log.info("Sending repomd directory to trash for cleanup (%s)", repomddir);
var router = require("./lib/router.js");
var cache = require("./lib/cache.js");
var maintain = require("./lib/maintain.js");
+var log = require("./lib/log.js");
// first we load the config...
-console.log("Loading configuration");
+log.info("Loading configuration");
config.loadConfig("./repos.conf");
// start the maintenance timer
-console.log("Starting cache maintenance timer");
+log.info("Starting cache maintenance timer");
maintain.startTimer();
// next we start our main request loop
repo:ubuntu:apt:http://ftp.iinet.net.au/pub/ubuntu/:1:120
# level for logging (1 = error, 2 = warning, 3=info, 4=debug);
-loggerlevel:3
+loggerlevel:4