Sotaro KARASAWA 10 лет назад
Родитель
Сommit
e43c6a3799
2 измененных файлов с 23 добавлено и 0 удалено
  1. 2 0
      README.md
  2. 21 0
      lib/crowi/index.js

+ 2 - 0
README.md

@@ -37,6 +37,7 @@ Dependencies
 
 * Node.js (4.2.x)
 * MongoDB
+* Elasticsearch (optional)
 * Redis (optional)
 * Amazon S3 (optional)
 * Facebook Application (optional)
@@ -59,6 +60,7 @@ $ PASSWORD_SEED=somesecretstring MONGO_URI=mongodb://username:password@localhost
 * `NODE_ENV`: `production` OR `development`.
 * `MONGO_URI`: URI to connect MongoDB. This parameter is also by `MONGOHQ_URL` OR `MONGOLAB_URI`.
 * `REDIS_URL`: URI to connect Redis (to session store). This parameter is also by `REDISTOGO_URL`.
+* `ELASTICSEARCH_URI`: URI to connect Elasticearch.
 * `PASSWORD_SEED`: A password seed is used by password hash generator.
 * `SECRET_TOKEN`: A secret key for verifying the integrity of signed cookies.
 * `FILE_UPLOAD`: `aws` (default), `local`, `none`

+ 21 - 0
lib/crowi/index.js

@@ -28,6 +28,7 @@ function Crowi (rootdir, env)
   this.mailDir   = path.join(this.viewsDir, 'mail') + sep;
 
   this.config = {};
+  this.searcher = {};
   this.mailer = {};
 
 
@@ -73,6 +74,8 @@ Crowi.prototype.init = function() {
         return resolve();
       });
     });
+  }).then(function() {
+    return self.setupSearcher();
   }).then(function() {
     return self.setupMailer();
   });
@@ -182,10 +185,28 @@ Crowi.prototype.getIo = function() {
   return this.io;
 };
 
+Crowi.prototype.getSearcher = function() {
+  return this.searcher;
+};
+
 Crowi.prototype.getMailer = function() {
   return this.mailer;
 };
 
+Crowi.prototype.setupSearcher = function() {
+  var self = this;
+  var searcherUri = this.env.ELASTICSEARCH_URI
+    || null
+    ;
+
+  return new Promise(function(resolve, reject) {
+    if (searcherUri) {
+      self.searcher = require('../util/searcher')(self);
+    }
+    resolve();
+  });
+};
+
 Crowi.prototype.setupMailer = function() {
   var self = this;
   return new Promise(function(resolve, reject) {