aboutsummaryrefslogtreecommitdiff
path: root/lib/compile-handler.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compile-handler.js')
-rw-r--r--lib/compile-handler.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/compile-handler.js b/lib/compile-handler.js
index 0f6790748..46844f559 100644
--- a/lib/compile-handler.js
+++ b/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) {