YUKI Hiroshi
null+****@clear*****
Thu Sep 18 17:02:50 JST 2014
YUKI Hiroshi 2014-09-18 17:02:50 +0900 (Thu, 18 Sep 2014) New Revision: ee40b1d103566f32eccad3024fe9f29779e57d68 https://github.com/droonga/droonga-http-server/commit/ee40b1d103566f32eccad3024fe9f29779e57d68 Message: Allow to define extra options before server options Modified files: bin/droonga-http-server lib/server-options.js Modified: bin/droonga-http-server (+1 -0) =================================================================== --- bin/droonga-http-server 2014-09-18 16:55:22 +0900 (14cd131) +++ bin/droonga-http-server 2014-09-18 17:02:50 +0900 (37ba581) @@ -15,6 +15,7 @@ var cookieParser = require('cookie-parser'), var defaultConfigs = require('../lib/default-configs'); var options = require('../lib/server-options'); +options = options.define().parse(process.argv); var baseDir = defaultConfigs.baseDir; Modified: lib/server-options.js (+45 -32) =================================================================== --- lib/server-options.js 2014-09-18 16:55:22 +0900 (3908956) +++ lib/server-options.js 2014-09-18 17:02:50 +0900 (3554c17) @@ -29,49 +29,62 @@ pluginsOption = function(newValue, oldValue) { }); } -options - .version(version) - .option('--port <port>', +options = options + .version(version); + +function add() { + options = options.apply(options, arguments); + return exports; +} +exports.add = add; + +function define() { + add('--port <port>', 'Port number (' + options.port + ')', - intOption) - .option('--receive-host-name <name>', + intOption); + add('--receive-host-name <name>', 'Host name of the protocol adapter. ' + 'It must be resolvable by Droonga engine. ' + - '(' + options.receiverHostName + ')') - .option('--droonga-engine-host-name <name>', - 'Host name of Droonga engine (' + options.droongaEngineHostName + ')') - .option('--droonga-engine-port <port>', + '(' + options.receiverHostName + ')'); + add('--droonga-engine-host-name <name>', + 'Host name of Droonga engine (' + options.droongaEngineHostName + ')'); + add('--droonga-engine-port <port>', 'Port number of Droonga engine (' + options.droongaEnginePort + ')', - intOption) - .option('--default-dataset <dataset>', - 'The default dataset (' + options.defaultDataset + ')') - .option('--tag <tag>', - 'The tag (' + options.tag + ')') - .option('--access-log-file <file>', + intOption); + add('--default-dataset <dataset>', + 'The default dataset (' + options.defaultDataset + ')'); + add('--tag <tag>', + 'The tag (' + options.tag + ')'); + add('--access-log-file <file>', 'Output access logs to <file>. ' + 'You can use "-" as <file> to output to the standard output. ' + - '(' + options.accessLogFile + ')') - .option('--system-log-file <file>', + '(' + options.accessLogFile + ')'); + add('--system-log-file <file>', 'Output system logs to <file>. ' + 'You can use "-" as <file> to output to the standard output. ' + - '(' + options.systemLogFile + ')') - .option('--cache-size <size>', + '(' + options.systemLogFile + ')'); + add('--cache-size <size>', 'The max number of cached requests ' + '(' + options.cacheSize + ')', - intOption) - .option('--enable-trust-proxy', + intOption); + add('--enable-trust-proxy', 'Enable "trust proxy" configuration. It is required when you run droonga-http-server behind a reverse proxy. ' + - '(' + options.enableTrustProxy + ')') - .option('--plugins <plugin1,plugin2,...>', + '(' + options.enableTrustProxy + ')'); + add('--plugins <plugin1,plugin2,...>', 'Use specified plugins. ' + '(' + options.plugins.join(',') + ')', - pluginsOption) - .option('--daemon', - 'Run as a daemon. (' + options.daemon + ')') - .option('--pid-file <pid-file>', - 'Output PID to <pid-file>.') - .option('--environment <environment>', - 'Use specified environment. (' + options.environment + ')') - .parse(process.argv); + pluginsOption); + add('--daemon', + 'Run as a daemon. (' + options.daemon + ')'); + add('--pid-file <pid-file>', + 'Output PID to <pid-file>.'); + add('--environment <environment>', + 'Use specified environment. (' + options.environment + ')'); + return exports; +} +exports.define = define; -module.exports = options; +function parse(argv) { + return options.parse(argv); +} +exports.parse = parse; -------------- next part -------------- HTML����������������������������...下载