Skip to content

Commit

Permalink
consul
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Nov 2, 2017
1 parent 724bfb8 commit fa88f5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions search.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ module.exports = function search (options) {
var url = 'http://'+elastic.host+':'+elastic.port+
'/'+elastic.base+'/mod/'+msg.data.name

console.log('INSERT URL: '+url)

Wreck.post(
url,
{json: true, payload: seneca.util.clean(msg.data)},
function (err, res, payload) {
console.log(err)

reply(err, payload)
})
}
Expand All @@ -45,7 +49,11 @@ module.exports = function search (options) {
var url = 'http://'+elastic.host+':'+elastic.port+
'/'+elastic.base+'/_search?q='+encodeURIComponent(msg.query)

console.log('SEARCH URL: '+url)

Wreck.get(url, {json: true}, function (err, res, payload) {
console.log(err)

if( err ) return reply(err)

var qr = payload
Expand Down
16 changes: 13 additions & 3 deletions srv/search-prod.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* Copyright (c) 2014-2017 Richard Rodger and other contributors, MIT License */

var BASES = process.env.BASES.split(',')
//var BASES = process.env.BASES.split(',')
var ELASTIC = process.env.ELASTIC_SERVICE_HOST || 'localhost'
var CONSUL = process.env.CONSUL_SERVICE_HOST || 'localhost'

var Seneca = require('seneca')

Expand All @@ -14,11 +15,20 @@ Seneca({tag: 'search'})
}
})

.use('consul-registry', {
host: CONSUL
})

.use('mesh', {
pin: 'role:search',
bases: BASES,
//bases: BASES,
host: '@eth0',
sneeze: {silent:false}
//sneeze: {silent:false},
discover: {
registry: {
active: true
}
},
})

.ready(function () {
Expand Down

0 comments on commit fa88f5d

Please sign in to comment.