diff --git a/src/consulWriter.js b/src/consulWriter.js index c2f4661..6f2d2c2 100644 --- a/src/consulWriter.js +++ b/src/consulWriter.js @@ -4,30 +4,30 @@ module.exports = { deregisterServices: deregisterServices }; -// Registers the specified services in consul (will auto-deregister first) +// Registers the specified services in consul function registerServices(consulHost, consulPort, services) { // Get consul var consul = require('consul')({ host: consulHost, port: consulPort }); // Enumerate the services - services.forEach(function (service) { - // Deregister the service by id, just in case - consul.agent.service.deregister({ id: service.id }, function (err) { + services.forEach(function (service) {// Register the service + consul.agent.service.register({ + name: service.name, + id: service.id, + address: service.address, + port: service.port, + tags: ['auto-registered'], + }, function (err) { // Handle error if (err) throw err; - - // Register the service - consul.agent.service.register({ - name: service.name, - id: service.id, - address: service.address, - port: service.port, - tags: ['auto-registered'], - }, function (err) { - // Handle error - if (err) throw err; - }); }); + // // Deregister the service by id, just in case + // consul.agent.service.deregister({ id: service.id }, function (err) { + // // Handle error + // if (err) throw err; + + + // }); }); }