Skip to content

Commit

Permalink
Don't auto-deregister (todo: be smarter about what's already registered)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaseajen committed Dec 17, 2015
1 parent 6ed6b7c commit 398b012
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/consulWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;


// });
});
}

Expand Down

0 comments on commit 398b012

Please sign in to comment.