Skip to content

Chris927/wait-for-host

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What?

Implements a single NodeJS function to wait for host/port to become available. Once available, a callback is called.

Example:

var waitForPort = require('wait-for-port');

waitForPort('my-host.com', 22, function(err) {
  if (err) throw new Error(err);
  // .. now we know that (at least for now) my-host.com is
  // listening on port 22
});

With options (these are the default, change as you see fit):

var options = {
  numRetries: 10, //Number of retries
  retryInterval: 1000 //Milliseconds to wait between retries
};

var waitForPort = require('wait-for-port');

waitForPort('my-host.com', 22, options, function(err) {
  if (err) throw new Error(err);
  // .. now we know that (at least for now) my-host.com is
  // listening on port 22
});

Check the specs for details and options.

Why?

This is useful e.g. when provisioning cloud stuff, e.g. call the EC2 API from Javascript to create instances, then wait for ssh to become available on all the hosts.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages