[Groonga-commit] droonga/droonga-http-server at 9b090a1 [master] Extract codes to read command line options for the server

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Sep 18 16:55:22 JST 2014


YUKI Hiroshi	2014-09-18 16:55:22 +0900 (Thu, 18 Sep 2014)

  New Revision: 9b090a17f7392a30617b207109ec81341267b53f
  https://github.com/droonga/droonga-http-server/commit/9b090a17f7392a30617b207109ec81341267b53f

  Message:
    Extract codes to read command line options for the server

  Added files:
    lib/server-options.js
  Modified files:
    bin/droonga-http-server

  Modified: bin/droonga-http-server (+1 -74)
===================================================================
--- bin/droonga-http-server    2014-09-18 16:48:43 +0900 (b22c11c)
+++ bin/droonga-http-server    2014-09-18 16:55:22 +0900 (14cd131)
@@ -6,91 +6,18 @@ var cookieParser = require('cookie-parser'),
     daemon       = require('daemon'),
     express      = require('express'),
     fs           = require('fs'),
-    yaml         = require('js-yaml'),
     http         = require('http'),
     morgan       = require('morgan'),
-    options      = require('commander'),
     path         = require('path'),
     responseTime = require('response-time'),
     session      = require('express-session'),
     winston      = require('winston');
 
-var version = require('../package.json').version;
 var defaultConfigs = require('../lib/default-configs');
+var options = require('../lib/server-options');
 
 var baseDir = defaultConfigs.baseDir;
 
-options.port             = defaultConfigs.port;
-options.accessLogFile    = defaultConfigs.access_log_file;
-options.systemLogFile    = defaultConfigs.system_log_file;
-options.daemon           = defaultConfigs.daemon;
-options.pidFile          = defaultConfigs.pid_file
-options.cacheSize        = defaultConfigs.cache_size;
-options.enableTrustProxy = defaultConfigs.enable_trust_proxy;
-options.plugins          = defaultConfigs.plugins;
-options.environment      = defaultConfigs.environment;
-
-options.droongaEngineHostName = defaultConfigs.engine.host;
-options.droongaEnginePort     = defaultConfigs.engine.port;
-options.tag                   = defaultConfigs.engine.tag;
-options.defaultDataset        = defaultConfigs.engine.default_dataset;
-options.receiverHostName      = defaultConfigs.engine.receiver_host;
-
-intOption = function(newValue, oldValue) {
-  return parseInt(newValue);
-}
-
-pluginsOption = function(newValue, oldValue) {
-  return newValue.split(/\s*,\s*/).map(function (plugin) {
-    return require(plugin);
-  });
-}
-
-options
-  .version(version)
-  .option('--port <port>',
-          'Port number (' + options.port + ')',
-          intOption)
-  .option('--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>',
-          '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>',
-          'Output access logs to <file>. ' +
-            'You can use "-" as <file> to output to the standard output. ' +
-            '(' + options.accessLogFile + ')')
-  .option('--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>',
-          'The max number of cached requests ' +
-            '(' + options.cacheSize + ')',
-          intOption)
-  .option('--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,...>',
-          '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);
-
 if (options.daemon) {
   daemon();
 }

  Added: lib/server-options.js (+77 -0) 100644
===================================================================
--- /dev/null
+++ lib/server-options.js    2014-09-18 16:55:22 +0900 (3908956)
@@ -0,0 +1,77 @@
+var options = require('commander');
+
+var version = require('../package.json').version;
+var defaultConfigs = require('./default-configs');
+
+options.port             = defaultConfigs.port;
+options.accessLogFile    = defaultConfigs.access_log_file;
+options.systemLogFile    = defaultConfigs.system_log_file;
+options.daemon           = defaultConfigs.daemon;
+options.pidFile          = defaultConfigs.pid_file
+options.cacheSize        = defaultConfigs.cache_size;
+options.enableTrustProxy = defaultConfigs.enable_trust_proxy;
+options.plugins          = defaultConfigs.plugins;
+options.environment      = defaultConfigs.environment;
+
+options.droongaEngineHostName = defaultConfigs.engine.host;
+options.droongaEnginePort     = defaultConfigs.engine.port;
+options.tag                   = defaultConfigs.engine.tag;
+options.defaultDataset        = defaultConfigs.engine.default_dataset;
+options.receiverHostName      = defaultConfigs.engine.receiver_host;
+
+intOption = function(newValue, oldValue) {
+  return parseInt(newValue);
+}
+
+pluginsOption = function(newValue, oldValue) {
+  return newValue.split(/\s*,\s*/).map(function (plugin) {
+    return require(plugin);
+  });
+}
+
+options
+  .version(version)
+  .option('--port <port>',
+          'Port number (' + options.port + ')',
+          intOption)
+  .option('--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>',
+          '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>',
+          'Output access logs to <file>. ' +
+            'You can use "-" as <file> to output to the standard output. ' +
+            '(' + options.accessLogFile + ')')
+  .option('--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>',
+          'The max number of cached requests ' +
+            '(' + options.cacheSize + ')',
+          intOption)
+  .option('--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,...>',
+          '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);
+
+module.exports = options;
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index