https://github.com/msyea/wait-for-blah
Utility that waits for docker containers to puke to the stdout
https://github.com/msyea/wait-for-blah
Last synced: 2 months ago
JSON representation
Utility that waits for docker containers to puke to the stdout
- Host: GitHub
- URL: https://github.com/msyea/wait-for-blah
- Owner: msyea
- Created: 2019-06-03T18:53:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T23:20:49.000Z (over 3 years ago)
- Last Synced: 2025-02-03T04:16:18.092Z (over 1 year ago)
- Language: JavaScript
- Size: 865 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wait-for-blah
An elegant utility that waits for docker containers to be ready by monitoring their stdout
# An example
This utility was inspired but this real life situation:
> You're waiting for a stub service (kafka) to be ready (create topics).
Unfortunately existing libraries such as the excellent `dadarek/wait-for-dependencies` report ready when the service starts listening via TCP on a port not when the topic is created. For some people this is premature.
# How it works
```yaml
version: "3"
services:
zookeeper:
image: wurstmeister/zookeeper
expose:
- "2181"
depends_on:
- kafka
kafka:
image: wurstmeister/kafka:2.11-1.1.1
exposr:
- "9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_CREATE_TOPICS: custom-topic-1:1:1,custom-topic-2:1:1
mongo:
image: mongo
tests:
build: ./tests
links:
- kafka
- stub
```
```ts
import wfb from 'wait-for-blah'
const waitForKafka = () => wfb('kafka', /Created log for partition/)
const waitForMongo = () => wfb('mongo', [/waiting for connections/])
(async () => {
await waitForKafka()
await waitForMongo()
await wfb('tests')
})()
```