https://github.com/bennycode/readyator
Check port to be ready before running a script.
https://github.com/bennycode/readyator
cli commands ports ready-to-run ready-to-use
Last synced: 3 months ago
JSON representation
Check port to be ready before running a script.
- Host: GitHub
- URL: https://github.com/bennycode/readyator
- Owner: bennycode
- Created: 2022-03-21T23:39:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-01T02:02:28.000Z (4 months ago)
- Last Synced: 2025-03-26T06:51:09.071Z (3 months ago)
- Topics: cli, commands, ports, ready-to-run, ready-to-use
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/readyator
- Size: 1.39 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Readyator
   
Waits for specified `urls` or `ports` on localhost to be ready before running a supplied command.
## Installation
### npm
```bash
npm install readyator
```### Yarn
```bash
yarn add readyator
```## Usage
### Preface
- Addresses (`ports` or `urls`) must be separated by comma if you want to check for multiple services to be ready ( returning a successful HTTP status code).
- Your `command` must be surrounded by quotes so that it can be properly parsed.
- The default check interval is 1s (1000ms) but can be changed.### Wait for ports
Command:
```bash
readyator [ports] [command]
```Example:
```bash
readyator 8080,8081 "npm run start"
```If you're not looking to perform any specific actions but simply want to determine when the service is available, use this command:
```bash
readyator 8080,8081 "exit 0"
```### Wait for URLs
Command:
```bash
readyator [urls] [command]
```Example:
```bash
readyator https://www.google.com/,http://localhost:8081/ "npm run start"
```### Change check interval
Command:
```bash
readyator [urls] [command] [interval_in_millis]
```Example:
```bash
readyator https://www.google.com/ "npm run start" 5000
```### Wait for healthy Docker container
Command:
```bash
readyator-docker [container_name] [interval_in_millis]
```Example:
```bash
readyator-docker my_docker_container 1000
```### Node.js API
You can use `readyator` also through its Node.js API:
```ts
import readyator from 'readyator';await readyator([8080, 8081], 'npm run start');
```It also supports executing a callback function:
```ts
import readyator from 'readyator';const callback = () => {
console.log('System is online!');
};readyator([8080, 8081], callback);
```Readyator's programmatic interface can also be used to listen for Docker containers to become healthy:
```ts
import {runWhenHealthy} from 'readyator';await runWhenHealthy('my_docker_container');
```## Development
Here is how you can easily test the `readyator` from your development environment when checking out the code:
```bash
npm start https://www.google.com/ "npm run exit"
```