eiriksm/wait-for-listen

Waits until a port is listening.

1.0.1 2017-09-04 18:09 UTC

This package is auto-updated.

Last update: 2024-10-23 15:14:30 UTC


README

Packagist Packagist Coverage Status Test Violinist enabled

Installation

composer require eiriksm/wait-for-listen

...or probably you want this as a dev requirement:

composer require eiriksm/wait-for-listen --dev

Usage

This package is useful to use in CI setups before your tests assume a service has started.

So instead of this:

- ./some-slow-starting-task-that-exposes-port 8000 &
- sleep 5
- composer test

You can now use this:

- ./some-slow-starting-task-that-exposes-port 8000 &
- ./vendor/bin/wait-for-listen 8000

Configuration

wait-for-listen has 3 options. Port, host and timeout.

They are specified like this:

./vendor/bin/wait-for-listen <port> [host] [timeout]

Port (required)

Specify a port to wait for.

Host (optional)

Specify an optional host. The default is 127.0.0.1.

Timeout (optional)

Specify a timeout. The default is 10.

Licence

WTFPL.