All Projects → typicode → server-ready

typicode / server-ready

Licence: MIT license
Know when a server is ready to receive requests

Programming Languages

javascript
184084 projects - #8 most used programming language

server-ready Build Status npm version

Know when a server is ready to receive requests. Used in hotel.

See server-ready-cli for the command-line tool.

Install

npm install server-ready --save

Example

var serverReady = require('server-ready')
var port = 3000

// A server process is spawned here or somewhere else...
serverReady(port, function (err) {
  if (err) return console.error('timeout, can\'t connect to port')
  console.log('port is open or has just opened')
})

How it works?

server-ready will try to connect every 250ms to the specified port until a connection has been made or timeout has been reached (20s by default).

API

serverReady.timeout

Default timeout.

serverReady(port[, host][, timeout], cb)

Tries to connect to port.

License

MIT - Typicode 🌵

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].