[Groonga-commit] groonga/gcs [master] Add new command line utilities

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 3日 (金) 18:11:56 JST


SHIMODA Hiroshi	2012-08-03 18:11:56 +0900 (Fri, 03 Aug 2012)

  New Revision: 0915970e6eec4004dd445e54f0c572c95cec8a38
  https://github.com/groonga/gcs/commit/0915970e6eec4004dd445e54f0c572c95cec8a38

  Log:
    Add new command line utilities

  Added files:
    bin/cs-create-domain
    bin/cs-describe-domain
    lib/command-line.js
  Modified files:
    bin/gcs

  Added: bin/cs-create-domain (+35 -0) 100755
===================================================================
--- /dev/null
+++ bin/cs-create-domain    2012-08-03 18:11:56 +0900 (f6ed664)
@@ -0,0 +1,35 @@
+#!/usr/bin/env node
+
+var program = require('commander');
+var commandLine = require(__dirname + '/../lib/command-line');
+
+program
+  .version(require('../package').version)
+  .usage('[options] --domain-name <domain name>')
+  .option('-d, --domain-name <domain name>',
+          'name for the new domain',
+          String)
+  .option('--database-path <path>',
+          'database path [' + commandLine.defaultDatabasePath + ']',
+          String,
+          commandLine.defaultDatabasePath)
+  .parse(process.argv);
+
+if (!program.domainName) {
+  console.log('You must specify the domain name.');
+  return false;
+}
+
+console.log('Creating domain [' + program.domainName + ']');
+
+var context = commandLine.getContext(program.databasePath);
+var domain = new commandLine.Domain(program.domainName, context);
+if (domain.exists()) {
+  console.log('The domain [' + program.domainName + '] already exists.');
+  return false;
+}
+
+domain.createSync();
+
+consoole.log('Domain endpoints are currently being created. ' +
+             'Use cs-describe-domain to check for endpoints.');

  Added: bin/cs-describe-domain (+42 -0) 100755
===================================================================
--- /dev/null
+++ bin/cs-describe-domain    2012-08-03 18:11:56 +0900 (0566ea9)
@@ -0,0 +1,42 @@
+#!/usr/bin/env node
+
+var program = require('commander');
+var commandLine = require(__dirname + '/../lib/command-line');
+
+program
+  .version(require('../package').version)
+  .usage('[options]')
+  .option('-d, --domain-name <domain name>',
+          'name for the new domain',
+          String)
+  .option('-all, --show-all',
+          'name for the new domain',
+          String)
+  .option('--database-path <path>',
+          'database path [' + commandLine.defaultDatabasePath + ']',
+          String,
+          commandLine.defaultDatabasePath)
+  .parse(process.argv);
+
+function report(domain) {
+  console.log('Domain Name               %s', domain.name);
+  console.log('Document Service Endpoint %s', domain.getDocumentsEndpoint('localhost'));
+  console.log('Search Endpoint           %s', domain.getSearchEndpoint('localhost'));
+  console.log('Searchable Documents      %s', domain.searchableDocumentsCount);
+  console.log('Index Fields              %s', domain.name);
+//  console.log('Ranking Fields            %s', ;
+  console.log('SearchPartitionCount      %s', domain.searchPartitionCount);
+  console.log('SearchInstanceCount       %s', domain.searchPartitionCount);
+  console.log('SearchInstanceType        %s', domain.searchInstanceType);
+}
+
+var context = commandLine.getContext(program.databasePath);
+if (program.domainName) {
+  var domain = new Domain(program.domainName, context);
+  report(domain);
+} else {
+  Domain.getAll(context).forEach(function(domain, index) {
+    if (index) console.log('========================================');
+    report(domain);
+  });
+}

  Modified: bin/gcs (+5 -7)
===================================================================
--- bin/gcs    2012-08-03 17:40:00 +0900 (991da76)
+++ bin/gcs    2012-08-03 18:11:56 +0900 (cf09ea1)
@@ -2,9 +2,7 @@
 
 var gcsServer = require(__dirname + '/../lib/server');
 var program = require('commander');
-
-var defaultDatabasePath = process.env.HOME + '/.gcs/database/gcs';
-var defaultPrivilegedRanges = '127.0.0.0/8';
+var commandLine = require(__dirname + '/../lib/command-line');
 
 program
   .version(require('../package').version)
@@ -14,14 +12,14 @@ program
           Number,
           7575)
   .option('--database-path <path>',
-          'database path [' + defaultDatabasePath + ']',
+          'database path [' + commandLine.defaultDatabasePath + ']',
           String,
-          defaultDatabasePath)
+          commandLine.defaultDatabasePath)
   .option('--privilege <ip range>',
           'list of IP ranges for privileged client '+
-            '[' + defaultPrivilegedRanges + ']',
+            '[' + commandLine.defaultPrivilegedRanges + ']',
           String,
-          defaultPrivilegedRanges)
+          commandLine.defaultPrivilegedRanges)
   .parse(process.argv);
 
 var server;

  Added: lib/command-line.js (+11 -0) 100644
===================================================================
--- /dev/null
+++ lib/command-line.js    2012-08-03 18:11:56 +0900 (ac636eb)
@@ -0,0 +1,11 @@
+var nroonga = require('./wrapped-nroonga');
+var context;
+
+exports.defaultDatabasePath = process.env.HOME + '/.gcs/database/gcs';
+exports.defaultPrivilegedRanges = '127.0.0.0/8';
+exports.getContext = function(databasePath) {
+  return context ||
+         (context = new nroonga.Context(databasePath || exports.defaultDatabasePath));
+};
+
+exports.Domain = require('./database/domain');
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Télécharger 



Groonga-commit メーリングリストの案内
Back to archive index