Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/177114

Change subject: Ensure that directories are initialized in GC thread.
......................................................................

Ensure that directories are initialized in GC thread.

The default directories were only being set in the backend thread, not
in the gc thread.  This only affects you if you were using the default
output directories.

Change the default temporary directory from /tmp to /tmp/ocg so that gc
doesn't try to clean up all of /tmp.

Change-Id: Ia391927ae7481371d280d945b59bd3f4a5610b1c
---
M lib/threads/backend.js
M lib/threads/gc.js
2 files changed, 21 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
 refs/changes/14/177114/1

diff --git a/lib/threads/backend.js b/lib/threads/backend.js
index b826616..bce3b4f 100644
--- a/lib/threads/backend.js
+++ b/lib/threads/backend.js
@@ -45,20 +45,18 @@
 
 /* === Public Exported Functions =========================================== */
 /**
- * Initialize the frontend server with global objects
+ * Set up the default temporary and output directories.
  *
- * @param {hash} config_obj - Configuration object
+ * @param {hash} config - Configuration object
  */
-function initBackend( config_obj ) {
-       var writer, paths;
+function initDirectories( config ) {
 
-       config = config_obj;
        if ( !config.backend.temp_dir ) {
                if ( os.tmpdir ) {
-                       config.backend.temp_dir = os.tmpdir();
+                       config.backend.temp_dir = path.join( os.tmpdir(), 'ocg' 
);
                } else {
                        // Node < 0.10
-                       config.backend.temp_dir = os.tmpDir();
+                       config.backend.temp_dir = path.join( os.tmpDir(), 'ocg' 
);
                }
        }
        // create the temp dir if necessary
@@ -69,6 +67,19 @@
        }
        // create the output directory if necessary
        mkdirp.sync(config.backend.output_dir);
+
+       return config;
+}
+
+/**
+ * Initialize the frontend server with global objects
+ *
+ * @param {hash} config_obj - Configuration object
+ */
+function initBackend( config_obj ) {
+       var writer, paths;
+
+       config = initDirectories( config_obj );
 
        redisClient = new Redis(
                config.redis.host,
@@ -687,5 +698,6 @@
 util.inherits( RendererError, BackendError );
 
 exports.init = initBackend;
+exports.initDirectories = initDirectories;
 exports.start = startBackend;
 exports.stop = stopBackend;
diff --git a/lib/threads/gc.js b/lib/threads/gc.js
index 21f56ca..9503833 100644
--- a/lib/threads/gc.js
+++ b/lib/threads/gc.js
@@ -36,6 +36,7 @@
 var fs = require( 'fs' );
 var path = require( 'path' );
 
+var backend = require( './backend.js' );
 var eh = require( '../errorhelper.js' );
 var jd = require( '../JobDetails.js' );
 var Redis = require( '../RedisWrapper.js' );
@@ -52,7 +53,7 @@
  * @param config_obj Configuration object
  */
 function init( config_obj ) {
-       config = config_obj;
+       config = backend.initDirectories( config_obj );
        redisClient = new Redis(
                config.redis.host,
                config.redis.port,

-- 
To view, visit https://gerrit.wikimedia.org/r/177114
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia391927ae7481371d280d945b59bd3f4a5610b1c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to