docs: function waitForStatus(port, host, inUse, retryTimeMs, timeOutMs) {
  
      var deferred = getDeferred();
      var timeoutId;
      var timedout = false;
      var retryId;
  
      // the first arument may be an object, if it is not, make an object
      var opts;
      if (is.obj(port)) {
          opts = port;
      } else {
          opts = makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs);
      }
  
      //debug('opts:'+util.inspect(opts);
  
      if (!is.bool(opts.inUse)) {
          deferred.reject(new Error('inUse must be a boolean'));
          return deferred.promise;
      }
  
      if (!is.positiveInt(opts.retryTimeMs)) {
          opts.retryTimeMs = RETRYTIME;
          debug('set retryTime to default '+RETRYTIME+'ms');
      }
  
      if (!is.positiveInt(opts.timeOutMs)) {
          opts.timeOutMs = TIMEOUT;
          debug('set timeOutMs to default '+TIMEOUT+'ms');
      }
  
      function cleanUp() {
          if (timeoutId) {
              clearTimeout(timeoutId);
          }
          if (retryId) {
              clearTimeout(retryId);
          }
      }
  
      function timeoutFunc() {
          timedout = true;
          cleanUp();
          deferred.reject(new Error('timeout'));
      }
      timeoutId = setTimeout(timeoutFunc, opts.timeOutMs);
  
      function doCheck() {
          check(opts.port, opts.host)
          .then(function(inUse) {
              if (timedout) {
                  return;
              }
              //debug('doCheck inUse: '+inUse);
              //debug('doCheck opts.inUse: '+opts.inUse);
              if (inUse === opts.inUse) {
                  deferred.resolve();
                  cleanUp();
                  return;
              } else {
                  retryId = setTimeout(function() { doCheck(); }, opts.retryTimeMs);
                  return;
              }
          }, function(err) {
              if (timedout) {
                  return;
              }
              deferred.reject(err);
              cleanUp();
          });
      }
  
      doCheck();
      return deferred.promise;
  }