lib/monitors/microservice-monitor.js
function checkMicroserviceHealth() {
  var resolver = Promise.pending();

  if (!zoologist.getServiceDiscovery() || !zoologist.getServiceDiscovery().getData()) {
    resolver.resolve({
      status: (zoologist.getClient().getClient().getState().name === 'SYNC_CONNECTED') ? 'UP' : 'DOWN'
    });

    return resolver.promise;
  }

  var health = {
    id: zoologist.getServiceDiscovery().getData().id,
    status: (zoologist.getClient().getClient().getState().name === 'SYNC_CONNECTED') ? 'UP' : 'DOWN',
    name: zoologist.getServiceInstance().getData().name,
    basePath: zoologist.getServiceInstance().getData().basePath || DEFAULT_BASE_PATH,
    address: zoologist.getServiceInstance().getData().address,
    port: zoologist.getServiceInstance().getData().port,
    registrationTime: new Date(zoologist.getServiceInstance().getData().registrationTimeUTC)
  };

  if (health.status === 'UP' && zoologist.getServiceDependencies() && zoologist.getServiceDependencies().length > 0) {
    checkDependencies(zoologist.getServiceDependencies(), function(err, dependencies) {
      health.dependencies = dependencies;

      // If any dependencies have zero count, set service 'DOWN'
      Object.keys(dependencies).forEach(function(dependency) {
        if (dependencies[dependency] == 0) health.status = 'DOWN';
      });

      resolver.resolve(health);
    });
  } else {
    resolver.resolve(health);
  }

  return resolver.promise;
}
function checkMicroserviceHealth() {
  var resolver = Promise.pending();

  if (!zoologist.getServiceDiscovery() || !zoologist.getServiceDiscovery().getData()) {
    resolver.resolve({
      status: (zoologist.getClient().getClient().getState().name === 'SYNC_CONNECTED') ? 'UP' : 'DOWN'
    });

    return resolver.promise;
  }

  var health = {
    id: zoologist.getServiceDiscovery().getData().id,
    status: (zoologist.getClient().getClient().getState().name === 'SYNC_CONNECTED') ? 'UP' : 'DOWN',
    name: zoologist.getServiceInstance().getData().name,
    basePath: zoologist.getServiceInstance().getData().basePath || DEFAULT_BASE_PATH,
    address: zoologist.getServiceInstance().getData().address,
    port: zoologist.getServiceInstance().getData().port,
    registrationTime: new Date(zoologist.getServiceInstance().getData().registrationTimeUTC)
  };

  if (health.status === 'UP' && zoologist.getServiceDependencies() && zoologist.getServiceDependencies().length > 0) {
    checkDependencies(zoologist.getServiceDependencies(), function(err, dependencies) {
      health.dependencies = dependencies;

      // If any dependencies have zero count, set service 'DOWN'
      Object.keys(dependencies).forEach(function(dependency) {
        if (dependencies[dependency] == 0) health.status = 'DOWN';
      });

      resolver.resolve(health);
    });
  } else {
    resolver.resolve(health);
  }

  return resolver.promise;
}
function checkMicroserviceHealth ( ) { var resolver = Promise . pending ( ) ; if ( ! zoologist . getServiceDiscovery ( ) || ! zoologist . getServiceDiscovery ( ) . getData ( ) ) { resolver . resolve ( { status : ( zoologist . getClient ( ) . getClient ( ) . getState ( ) . name === 'SYNC_CONNECTED' ) ? 'UP' : 'DOWN' } ) ; return resolver . promise ; } var health = { id : zoologist . getServiceDiscovery ( ) . getData ( ) . id , status : ( zoologist . getClient ( ) . getClient ( ) . getState ( ) . name === 'SYNC_CONNECTED' ) ? 'UP' : 'DOWN' , name : zoologist . getServiceInstance ( ) . getData ( ) . name , basePath : zoologist . getServiceInstance ( ) . getData ( ) . basePath || DEFAULT_BASE_PATH , address : zoologist . getServiceInstance ( ) . getData ( ) . address , port : zoologist . getServiceInstance ( ) . getData ( ) . port , registrationTime : new Date ( zoologist . getServiceInstance ( ) . getData ( ) . registrationTimeUTC ) } ; if ( health . status === 'UP' && zoologist . getServiceDependencies ( ) && zoologist . getServiceDependencies ( ) . length > 0 ) { checkDependencies ( zoologist . getServiceDependencies ( ) , function ( err , dependencies ) { health . dependencies = dependencies ; // If any dependencies have zero count, set service 'DOWN' Object . keys ( dependencies ) . forEach ( function ( dependency ) { if ( dependencies [ dependency ] == 0 ) health . status = 'DOWN' ; } ) ; resolver . resolve ( health ) ; } ) ; } else { resolver . resolve ( health ) ; } return resolver . promise ; }
Invoke health check.
Invoke health check .