Created
December 30, 2016 07:01
-
-
Save zacck-zz/5aa1c9be51a59f37bd0df3608a3f3502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let us attempt to start the cluster | |
var elasticsearch = require('elasticsearch'); | |
var conf = require('../config'); | |
var fbutil = require('../lib/fbutil'); | |
var PathMonitor = require('../lib/PathMonitor'); | |
var SearchQueue = require('../lib/SearchQueue'); | |
var escOptions = { | |
hosts: [{ | |
host: conf.ES_HOST, | |
port: conf.ES_PORT, | |
auth: (conf.ES_USER && conf.ES_PASS) ? conf.ES_USER + ':' + conf.ES_PASS : null | |
}] | |
}; | |
for (var attrname in conf.ES_OPTS) { | |
if( conf.ES_OPTS.hasOwnProperty(attrname) ) { | |
escOptions[attrname] = conf.ES_OPTS[attrname]; | |
} | |
} | |
// connect to ElasticSearch | |
var esc = new elasticsearch.Client(escOptions); | |
console.log('Connecting to ElasticSearch host %s:%s'.grey, conf.ES_HOST, conf.ES_PORT); | |
var timeoutObj = setInterval(function() { | |
esc.ping() | |
.then(function() { | |
console.log('Connected to ElasticSearch host %s:%s'.grey, conf.ES_HOST, conf.ES_PORT); | |
clearInterval(timeoutObj); | |
initFlashlight(); | |
}); | |
}, 5000); | |
function initFlashlight() { | |
console.log('Connecting to Firebase %s'.grey, conf.FB_URL); | |
fbutil.init(conf.FB_URL, conf.FB_SERVICEACCOUNT); | |
PathMonitor.process(esc, conf.paths, conf.FB_PATH); | |
SearchQueue.init(esc, conf.FB_REQ, conf.FB_RES, conf.CLEANUP_INTERVAL); | |
} | |
//end cluster work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment