dockerApi.js
function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) {
  if (pollCount === undefined) {
    pollCount = 0;
  }

  logger.info({
    user: user,
    identityFile: sshKeyPath,
    ipAddress: ipaddress
  }, 'waiting for connectivity');

  portscanner.checkPortStatus(22, ipaddress, function(err, status) {
    if (status === 'closed') {
      if (pollCount > MAX_POLLS) {
        pollCount = 0;
        cb('timeout exceeded - unable to connect to: ' + ipaddress);
      }
      else {
        pollCount = pollCount + 1;
        setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL);
      }
    }
    else if (status === 'open') {
      pollCount = 0;
      sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) {
        cb(err);
      });
    }
  });
}
function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) {
  if (pollCount === undefined) {
    pollCount = 0;
  }

  logger.info({
    user: user,
    identityFile: sshKeyPath,
    ipAddress: ipaddress
  }, 'waiting for connectivity');

  portscanner.checkPortStatus(22, ipaddress, function(err, status) {
    if (status === 'closed') {
      if (pollCount > MAX_POLLS) {
        pollCount = 0;
        cb('timeout exceeded - unable to connect to: ' + ipaddress);
      }
      else {
        pollCount = pollCount + 1;
        setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL);
      }
    }
    else if (status === 'open') {
      pollCount = 0;
      sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) {
        cb(err);
      });
    }
  });
}
function preconnect ( user , sshKeyPath , ipaddress , cb , pollCount ) { if ( pollCount === undefined ) { pollCount = 0 ; } logger . info ( { user : user , identityFile : sshKeyPath , ipAddress : ipaddress } , 'waiting for connectivity' ) ; portscanner . checkPortStatus ( 22 , ipaddress , function ( err , status ) { if ( status === 'closed' ) { if ( pollCount > MAX_POLLS ) { pollCount = 0 ; cb ( 'timeout exceeded - unable to connect to: ' + ipaddress ) ; } else { pollCount = pollCount + 1 ; setTimeout ( function ( ) { preconnect ( user , sshKeyPath , ipaddress , cb , pollCount ) ; } , POLL_INTERVAL ) ; } } else if ( status === 'open' ) { pollCount = 0 ; sshCheck . check ( ipaddress , user , sshKeyPath , null , function ( err ) { cb ( err ) ; } ) ; } } ) ; }
preconnect in the case that ssh multiplexing is operative
preconnect in the case that ssh multiplexing is operative