diff options
author | Matt Godbolt <matt@godbolt.org> | 2017-01-14 23:39:19 -0600 |
---|---|---|
committer | Matt Godbolt <matt@godbolt.org> | 2017-01-14 23:39:19 -0600 |
commit | 47195c29dc0c5297800d610666dd63393bd3d50c (patch) | |
tree | ef2a9d2f4f82a37c14ba6969e3f2dc23fd96c021 /lib/compile-handler.js | |
parent | 23efc05167be188b5fea74c581cbeee12a384062 (diff) | |
download | compiler-explorer-47195c29dc0c5297800d610666dd63393bd3d50c.tar.gz compiler-explorer-47195c29dc0c5297800d610666dd63393bd3d50c.zip |
Don't clean up temp diretories if there are pending compilations. Fixes #212.
Diffstat (limited to 'lib/compile-handler.js')
-rw-r--r-- | lib/compile-handler.js | 22 |
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) { |