Browse Source

Don't clean up temp diretories if there are pending compilations. Fixes #212.

dev/git-series/gccdum
Matt Godbolt 6 years ago
parent
commit
47195c29dc
  1. 4
      lib/compilation-env.js
  2. 22
      lib/compile-handler.js

4
lib/compilation-env.js

@ -100,6 +100,10 @@ CompilationEnvironment.prototype.enqueue = function (job) {
return this.compileQueue.add(job);
};
CompilationEnvironment.prototype.isBusy = function () {
return this.compileQueue.getPendingLength() > 0 || this.compileQueue.getQueueLength() > 0;
};
CompilationEnvironment.prototype.findBadOptions = function (options) {
return _.filter(options, function (option) {
return !option.match(this.okOptions) || option.match(this.badOptions);

22
lib/compile-handler.js

@ -33,26 +33,28 @@ var child_process = require('child_process'),
temp.track();
function periodicCleanup() {
temp.cleanup(function (err, stats) {
if (err) logger.error("Error cleaning directories: ", err);
if (stats) logger.debug("Directory cleanup stats:", stats);
});
}
var oneTimeInit = false;
function initialise(gccProps, compilerProps) {
function initialise(gccProps, compilerEnv) {
if (oneTimeInit) return;
oneTimeInit = true;
var tempDirCleanupSecs = gccProps("tempDirCleanupSecs", 600);
logger.info("Cleaning temp dirs every " + tempDirCleanupSecs + " secs");
setInterval(periodicCleanup, tempDirCleanupSecs * 1000);
setInterval(function () {
if (compilerEnv.isBusy()) {
logger.warn("Skipping temporary file clean up as compiler environment is busy");
return;
}
temp.cleanup(function (err, stats) {
if (err) logger.error("Error cleaning directories: ", err);
if (stats) logger.debug("Directory cleanup stats:", stats);
});
}, tempDirCleanupSecs * 1000);
}
function CompileHandler(gccProps, compilerProps) {
initialise(gccProps, compilerProps);
this.compilersById = {};
this.compilerEnv = new CompilationEnvironment(gccProps, compilerProps);
initialise(gccProps, this.compilerEnv);
this.factories = {};
this.create = function (compiler) {

Loading…
Cancel
Save