await-resource

0.3.0 • Public • Published

await-resource

Simple utility tool which polls a resource (e.g. a database) until it is up. Useful e.g. in dev startup scripts. Currently only usable from npm scripts (or the command line), and works only for resources running in Docker containers.

E.g. await-resource --pg POSTGRES_CONTAINER_NAME_1 --pg POSTGRES_CONTAINER_NAME_2 --timeout 20000 waits until the postgres instances running in the two docker containers are BOTH up, or until the timeout of (20000ms = 20s) runs out - it throws an error in the latter case.

Usage

Postgres

await-resource --pg CONTAINER_NAME

RabbitMQ

await-resource --rabbit CONTAINER_NAME

Redis

await-resource --redis CONTAINER_NAME

MongoDB

await-resource --mongo CONTAINER_NAME

Firestore emulator

await-resource --firestore CONTAINER_NAME

URLs

await-resource --url SOME_URL polls the given URL until it returns a 2xx status code.

Configuration

You can wait for any number of resources in any combination in one command.

The default polling interval is 500ms, you can override it with e.g. --interval 100.

The default timeout value is 120000ms (2 minutes), you can override it with e.g. --timeout 10000.

Dependencies (3)

Dev Dependencies (1)

Package Sidebar

Install

npm i await-resource

Weekly Downloads

10

Version

0.3.0

License

ISC

Unpacked Size

7.67 kB

Total Files

6

Last publish

Collaborators

  • cztamas