https://github.com/swarthy/wait-for
utilites for waiting in docker
https://github.com/swarthy/wait-for
Last synced: 6 months ago
JSON representation
utilites for waiting in docker
- Host: GitHub
- URL: https://github.com/swarthy/wait-for
- Owner: swarthy
- License: mit
- Created: 2018-03-15T05:02:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-23T19:15:58.000Z (over 3 years ago)
- Last Synced: 2025-10-24T16:40:16.090Z (9 months ago)
- Language: JavaScript
- Size: 798 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wait-for
[![NPM version][npm-image]][npm-url]
[![Build status][ci-image]][ci-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
_wait-for_ will try connect to server then exit with code `0` if server is available and `1` otherwise.
## Usage
### PostgreSQL
```bash
wait-for --postgresql postgres://postgres@localhost && npm run test-integration
# or
POSTGRESQL_URI=postgres://postgres@localhost wait-for --postgresql && npm run test-integration
```
### RabbitMQ
```bash
wait-for --rabbitmq amqp://localhost && npm run test-integration
# or
RABBITMQ_URI=amqp://localhost wait-for --rabbitmq && npm run test-integration
```
### Redis
```bash
wait-for --redis redis://localhost && npm run test-integration
# or
REDIS_URI=redis://localhost wait-for --redis && npm run test-integration
```
### Example
Wait for PostgreSQL, RabbitMQ and Redis (configured via environment)
```bash
wait-for --postgresql --rabbitmq --redis && npm run test-integration
```
## Configuration
| CLI argument | Environment variable | Description | Default |
| ------------------ | -------------------- | ---------------------- | ------- |
| --postgressql | `POSTGRESQL_URI` | Connection string | |
| --rabbitmq | `RABBITMQ_URI` | Connection string | |
| --redis | `REDIS_URI` | Connection string | |
| -c, --max-attempts | | Max attempt count | 60 |
| -d, --delay | | Delay between attempts | 1000 |
| -q, --quiet | | Quiet mode | |
### Used packages
[amqplib](https://www.npmjs.com/package/amqplib)
[pg](https://www.npmjs.com/package/pg)
[redis](https://www.npmjs.com/package/redis)
[npm-image]: https://img.shields.io/npm/v/@swarthy/wait-for.svg?style=flat-square
[npm-url]: https://npmjs.org/package/wait-for
[ci-image]: https://github.com/swarthy/wait-for/actions/workflows/main.yml/badge.svg
[ci-url]: https://github.com/swarthy/wait-for/actions/workflows/main.yml
[daviddm-image]: http://img.shields.io/david/swarthy/wait-for.svg?style=flat-square
[daviddm-url]: https://david-dm.org/swarthy/wait-for
[snyk-image]: https://snyk.io/test/npm/@swarthy/wait-for/badge.svg
[snyk-url]: https://snyk.io/test/npm/@swarthy/wait-for