Permalink
Browse files

Make first poll occur immediately on run

  • Loading branch information...
1 parent 4d1e42e commit ad286fe05ef11ac060a4303ce07b664fad8155bf @DukeyToo DukeyToo committed Feb 10, 2012
Showing with 10 additions and 3 deletions.
  1. +7 −2 bin/proxy.js
  2. +3 −1 lib/main.js
View
@@ -28,7 +28,8 @@ parser.on("server", function(config, callback) {
perfectapi.proxy(endpoint, function(err, registry) {
//now we have a reference to the registry running on the same machine
- setInterval(function() {
+
+ var poller = function() {
var config = {}
registry.listServices(config, function(err, result) {
if (err) return console.log(err);
@@ -37,7 +38,11 @@ parser.on("server", function(config, callback) {
if (err) return console.log(err);
});
})
- }, pollInterval);
+ }
+
+ poller();
+
+ setInterval(poller, pollInterval);
});
})
View
@@ -9,8 +9,10 @@ exports.poll = function(registry, serviceNames, callback) {
async.forEach(serviceNames, function(serviceName, cb) {
var config = {name: serviceName};
- console.log(serviceName)
+
registry.getServiceInfo(config, function(err, result) {
+ if (err) return cb(err);
+
console.log(result);
async.filter(result, function(instance, cb2) {
cb2(instance.host && instance.host.toLowerCase() == hostName);

0 comments on commit ad286fe

Please sign in to comment.