← 返回命令列表

Linux command

wait4x 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Wait for a TCP port

wait4x tcp [localhost:8080]

Wait for an HTTP endpoint

wait4x http [https://api.example.com/health] --expect-status-code [200]

Wait for multiple services

wait4x tcp [127.0.0.1:5432] [127.0.0.1:6379] [127.0.0.1:27017]

Wait for a service and then run a command

wait4x tcp [localhost:3306] -- [./start-app.sh]

Wait for a DNS record

wait4x dns A [example.com] --expected-ip [93.184.216.34]

Wait for PostgreSQL

wait4x postgresql 'postgres://[user]:[password]@[localhost]:5432/[mydb]?sslmode=disable'

Wait for Redis

wait4x redis redis://[localhost]:6379 --expect-key "[status]=^ready$"

Wait for a service to become unavailable

wait4x tcp [localhost:8080] --invert-check

说明

wait4x is a lightweight, zero-dependency tool for waiting until services reach a ready state. It supports TCP, HTTP, DNS, and direct integrations with databases and message brokers including MySQL, PostgreSQL, MongoDB, Redis, RabbitMQ, Kafka, InfluxDB, and Temporal. Multiple targets can be specified to check services in parallel. The --invert-check flag reverses the logic to wait for services to become unavailable. After a successful check, an arbitrary command can be executed by appending -- followed by the command. wait4x supports configurable timeouts, retry intervals, and exponential backoff strategies, making it suitable for CI/CD pipelines, container orchestration, deployment scripts, and local development environments.

参数

--timeout _duration_
Maximum wait duration (e.g., 30s).
--interval _duration_
Check frequency (default: 1s).
--invert-check
Wait for service to become unavailable instead.
--backoff-policy _policy_
Retry strategy (e.g., exponential).
--backoff-exponential-coefficient _n_
Multiplier per retry (e.g., 2.0).
--backoff-exponential-max-interval _duration_
Maximum interval between retries.
--expect-status-code _code_
Expected HTTP response code (http subcommand).
--expect-body-regex _pattern_
Pattern match in HTTP response body.
--expect-body-json _path_
JSON path validation using GJSON syntax.
--expect-body-xpath _expression_
XPath evaluation on HTML/XML response.
--expect-header _header=value_
Expected HTTP response header.
--request-header _header_
Custom HTTP request header (repeatable).
--expect-key _key_
Expected Redis key, optionally with value regex (key=regex).
--expect-table _table_
Expected database table (mysql/postgresql subcommands).
--expected-ip _ip_
Expected IP address for DNS A/AAAA records.
--expected-domain _domain_
Expected domain for DNS CNAME/MX records.
-n _server_
DNS nameserver to query.

FAQ

What is the wait4x command used for?

wait4x is a lightweight, zero-dependency tool for waiting until services reach a ready state. It supports TCP, HTTP, DNS, and direct integrations with databases and message brokers including MySQL, PostgreSQL, MongoDB, Redis, RabbitMQ, Kafka, InfluxDB, and Temporal. Multiple targets can be specified to check services in parallel. The --invert-check flag reverses the logic to wait for services to become unavailable. After a successful check, an arbitrary command can be executed by appending -- followed by the command. wait4x supports configurable timeouts, retry intervals, and exponential backoff strategies, making it suitable for CI/CD pipelines, container orchestration, deployment scripts, and local development environments.

How do I run a basic wait4x example?

Run `wait4x tcp [localhost:8080]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --timeout _duration_ do in wait4x?

Maximum wait duration (e.g., 30s).