Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/159099
Change subject: Use `/etc/mw-collection-ocg.js` configuration file if present.
......................................................................
Use `/etc/mw-collection-ocg.js` configuration file if present.
The documentation at the top of `defaults.js` mentions this file, but it
is nowhere loaded by default. Since the provided upstart file doesn't
specify a `-c` option, we need to look for this override in a different way.
Note that this allows multiple levels of configuration -- the distribution's
default configuration file in `/etc/mw-collection-ocg.js` can specify another
more-local configuration in `/usr/local/etc/` which can then in turn fall
back to a user configuration in `$HOME`, etc.
Change-Id: Ie50b823d7dec510b30f5366c83e371c685576fee
---
M README.md
M defaults.js
M mw-ocg-service.js
3 files changed, 26 insertions(+), 1 deletion(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
refs/changes/99/159099/1
diff --git a/README.md b/README.md
index e1763f3..827bfe4 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,18 @@
## Installation on Ubuntu
-```
+Ensure that you have a redis server installed somewhere.
+
+```sh
+cd <repodir> ; npm install
ln -s <repodir>/mw-collection-ocg.conf /etc/init
initctl reload-configuration
service mw-collection-ocg start
```
+Create `/etc/mw-collection-ocg.js` to configure the render service.
+See [the default configuration](./defaults.js) for more details.
+
## Binary node modules
The following node binary modules are required:
* hiredis
diff --git a/defaults.js b/defaults.js
index 31aa9bf..e8d8bae 100644
--- a/defaults.js
+++ b/defaults.js
@@ -6,6 +6,9 @@
* module.exports = function(config) { config.foo = 'bar'; }
*/
module.exports = {
+ /** Location of local configuration override(s) (if present) */
+ "config": "/etc/mw-collection-ocg.js",
+
/** Service management thread, coordinates (re)launching threads and
initial global setup */
"coordinator": {
/** The number of frontend threads to spawn. At the moment we
don't have good data on how
diff --git a/mw-ocg-service.js b/mw-ocg-service.js
index c93be03..9959ee0 100755
--- a/mw-ocg-service.js
+++ b/mw-ocg-service.js
@@ -34,6 +34,7 @@
var cluster = require( 'cluster' );
var commander = require( 'commander' );
+var fs = require('fs');
var path = require( 'path' );
var StatsD = require( './lib/statsd.js' );
var os = require( 'os' );
@@ -41,6 +42,21 @@
/* === Configuration Options & File ======================================== */
var config = require( './defaults.js' );
+// local configuration overrides
+var config_done = Object.create(null);
+while (config.config) {
+ if (config_done['$'+config.config]) {
+ break;
+ }
+ config_done['$'+config.config] = true;
+ try {
+ fs.statSync(config.config);
+ } catch (e) {
+ break; // file not present
+ }
+ config = require( config.config )( config );
+}
+// parse command-line options (with a possible additional config file override)
commander
.version( '0.0.1' )
.option( '-c, --config <path>', 'Path to the local configuration file' )
--
To view, visit https://gerrit.wikimedia.org/r/159099
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie50b823d7dec510b30f5366c83e371c685576fee
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