# tcpw
`tcpw` (TCP Wait) is a tool that waits until TCP endpoints are open.
It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers.
That is yet another alternative to `wait-for-it.sh`.
## Rationale
- available as a binary executable without any dependencies (file size <1mb).
- Optimized with: `-ldflags="-s -w" -trimpath` and `upx`
- Pre-built binaries:
- [tcpw-linux-x86_64](https://raw.githubusercontent.com/jackcvr/tcpw/main/x86_64/tcpw/tcpw)
- [tcpw-linux-aarch64](https://raw.githubusercontent.com/jackcvr/tcpw/main/aarch64/tcpw/tcpw)
- [tcpw-linux-armv7l](https://raw.githubusercontent.com/jackcvr/tcpw/main/armv7l/tcpw/tcpw)
- available on `PyPI`
- additionally, you can set:
- more than one endpoint: `-a google.com:80 -a booble.gum:8080 ...`
- command, which can be executed only after success, failure or any result: `-on f -a google.com:9999 echo "Endpoint is down"`
- polling interval: `-i 500ms`
- `timeout/interval` in different time units: `ns,ms,s,m,h`
## Installation
Download executable file:
`sh -c "wget -O tcpw https://raw.githubusercontent.com/jackcvr/tcpw/main/$(uname -m)/tcpw/tcpw && chmod +x tcpw"`
or:
- x86_64: `pip install tcpw`
- aarch64: `pip install tcpw[arm64]`
- armv7l: `pip install tcpw[armv7l]`
[![PyPI - Version](https://img.shields.io/pypi/v/tcpw.svg)](https://pypi.org/project/tcpw)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tcpw.svg)](https://pypi.org/project/tcpw)
## Usage
```text
Usage: tcpw [-t timeout] [-i interval] [-on (s|f|any)] [-q] [-v] [-a host:port ...] [command [args]]
-a value
Endpoint to await, in the form 'host:port'
-i duration
Interval between retries in format N{ns,ms,s,m,h} (default 1s)
-on string
Condition for command execution. Possible values: 's' - after success, 'f' - after failure, 'any' - always (default "s")
-q Do not print anything (default false)
-t duration
Timeout in format N{ns,ms,s,m,h}, e.g. '5s' == 5 seconds. Zero for no timeout (default 0)
-v Verbose mode (default false)
command args
Execute command with arguments after the test finishes (default: if connection succeeded)
```
## Examples
Wait 5 seconds for port 80 on `www.google.com`, and if it is available, echo the message `Google is up`:
```bash
$ tcpw -t 5s -a www.google.com:80 echo "Google is up"
2024/08/26 20:06:47.209012 successfully connected to www.google.com:80
Google is up
```
Next command waits 2 seconds for www.google.com:80 and localhost:5000, checking them every 500 milliseconds
with enabled verbose mode and executes `echo` regardless of the result:
```bash
$ tcpw -t 2s -i 500ms -v -on any -a www.google.com:80 -a localhost:5000 echo "Printed anyway"
2024/08/26 20:08:24.153240 connecting to localhost:5000...
2024/08/26 20:08:24.153327 connecting to www.google.com:80...
2024/08/26 20:08:24.153541 dial tcp 127.0.0.1:5000: connect: connection refused
2024/08/26 20:08:24.179927 successfully connected to www.google.com:80
2024/08/26 20:08:24.654984 dial tcp 127.0.0.1:5000: connect: connection refused
2024/08/26 20:08:25.155997 dial tcp 127.0.0.1:5000: connect: connection refused
2024/08/26 20:08:25.661397 dial tcp 127.0.0.1:5000: connect: connection refused
2024/08/26 20:08:26.161613 dial tcp: lookup localhost: i/o timeout
timeout error
Printed anyway
```
## License
[MIT](https://spdx.org/licenses/MIT.html)
Raw data
{
"_id": null,
"home_page": null,
"name": "tcpw-armv7l",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": null,
"keywords": "wait-for-it, waitforit, tcp, expect, docker, containers",
"author": null,
"author_email": "Andrii Kuzmin <jack.cvr@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/36/7b/8829299185f535ba49e84f46317e36006ff4be54572d2e27d249ebf33632/tcpw_armv7l-0.1.9.tar.gz",
"platform": null,
"description": "# tcpw\n\n`tcpw` (TCP Wait) is a tool that waits until TCP endpoints are open.\n\nIt is useful for synchronizing the spin-up of interdependent services, such as linked docker containers.\n\nThat is yet another alternative to `wait-for-it.sh`.\n\n## Rationale\n\n- available as a binary executable without any dependencies (file size <1mb).\n - Optimized with: `-ldflags=\"-s -w\" -trimpath` and `upx`\n - Pre-built binaries:\n - [tcpw-linux-x86_64](https://raw.githubusercontent.com/jackcvr/tcpw/main/x86_64/tcpw/tcpw)\n - [tcpw-linux-aarch64](https://raw.githubusercontent.com/jackcvr/tcpw/main/aarch64/tcpw/tcpw)\n - [tcpw-linux-armv7l](https://raw.githubusercontent.com/jackcvr/tcpw/main/armv7l/tcpw/tcpw)\n- available on `PyPI`\n- additionally, you can set:\n - more than one endpoint: `-a google.com:80 -a booble.gum:8080 ...`\n - command, which can be executed only after success, failure or any result: `-on f -a google.com:9999 echo \"Endpoint is down\"`\n - polling interval: `-i 500ms`\n - `timeout/interval` in different time units: `ns,ms,s,m,h`\n\n\n## Installation\n\nDownload executable file:\n\n`sh -c \"wget -O tcpw https://raw.githubusercontent.com/jackcvr/tcpw/main/$(uname -m)/tcpw/tcpw && chmod +x tcpw\"`\n\nor:\n\n- x86_64: `pip install tcpw`\n- aarch64: `pip install tcpw[arm64]`\n- armv7l: `pip install tcpw[armv7l]` \n\n[![PyPI - Version](https://img.shields.io/pypi/v/tcpw.svg)](https://pypi.org/project/tcpw)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tcpw.svg)](https://pypi.org/project/tcpw)\n\n## Usage\n\n```text\nUsage: tcpw [-t timeout] [-i interval] [-on (s|f|any)] [-q] [-v] [-a host:port ...] [command [args]]\n\n -a value\n \tEndpoint to await, in the form 'host:port'\n -i duration\n \tInterval between retries in format N{ns,ms,s,m,h} (default 1s)\n -on string\n \tCondition for command execution. Possible values: 's' - after success, 'f' - after failure, 'any' - always (default \"s\")\n -q\tDo not print anything (default false)\n -t duration\n \tTimeout in format N{ns,ms,s,m,h}, e.g. '5s' == 5 seconds. Zero for no timeout (default 0)\n -v\tVerbose mode (default false)\n command args\n \tExecute command with arguments after the test finishes (default: if connection succeeded)\n```\n\n## Examples\n\nWait 5 seconds for port 80 on `www.google.com`, and if it is available, echo the message `Google is up`:\n\n```bash\n$ tcpw -t 5s -a www.google.com:80 echo \"Google is up\"\n2024/08/26 20:06:47.209012 successfully connected to www.google.com:80\nGoogle is up\n```\n\nNext command waits 2 seconds for www.google.com:80 and localhost:5000, checking them every 500 milliseconds\nwith enabled verbose mode and executes `echo` regardless of the result:\n\n```bash\n$ tcpw -t 2s -i 500ms -v -on any -a www.google.com:80 -a localhost:5000 echo \"Printed anyway\"\n2024/08/26 20:08:24.153240 connecting to localhost:5000...\n2024/08/26 20:08:24.153327 connecting to www.google.com:80...\n2024/08/26 20:08:24.153541 dial tcp 127.0.0.1:5000: connect: connection refused\n2024/08/26 20:08:24.179927 successfully connected to www.google.com:80\n2024/08/26 20:08:24.654984 dial tcp 127.0.0.1:5000: connect: connection refused\n2024/08/26 20:08:25.155997 dial tcp 127.0.0.1:5000: connect: connection refused\n2024/08/26 20:08:25.661397 dial tcp 127.0.0.1:5000: connect: connection refused\n2024/08/26 20:08:26.161613 dial tcp: lookup localhost: i/o timeout\ntimeout error\nPrinted anyway\n```\n\n## License\n\n[MIT](https://spdx.org/licenses/MIT.html) \n",
"bugtrack_url": null,
"license": null,
"summary": "Wait until TCP endpoints are open",
"version": "0.1.9",
"project_urls": {
"Documentation": "https://github.com/jackcvr/tcpw#readme",
"Issues": "https://github.com/jackcvr/tcpw/issues",
"Source": "https://github.com/jackcvr/tcpw"
},
"split_keywords": [
"wait-for-it",
" waitforit",
" tcp",
" expect",
" docker",
" containers"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "273ca6e86afda633f67062bc70e9117e60dcdcfe54fcf03c557f50de6df34546",
"md5": "766b6ec6d0a62f26574304997f5ad611",
"sha256": "b8066167e98203c517fdf4374ff61ee95a3b344bc88f1da764166e33b0ccfc23"
},
"downloads": -1,
"filename": "tcpw_armv7l-0.1.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "766b6ec6d0a62f26574304997f5ad611",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 822833,
"upload_time": "2024-09-04T13:12:19",
"upload_time_iso_8601": "2024-09-04T13:12:19.027341Z",
"url": "https://files.pythonhosted.org/packages/27/3c/a6e86afda633f67062bc70e9117e60dcdcfe54fcf03c557f50de6df34546/tcpw_armv7l-0.1.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "367b8829299185f535ba49e84f46317e36006ff4be54572d2e27d249ebf33632",
"md5": "40b7e0037c004c20b9eb22b89621ad7e",
"sha256": "4d0b2d1d920f4464b7144c666ee001432ce59b2da0efbea370fe33bac182d417"
},
"downloads": -1,
"filename": "tcpw_armv7l-0.1.9.tar.gz",
"has_sig": false,
"md5_digest": "40b7e0037c004c20b9eb22b89621ad7e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 825371,
"upload_time": "2024-09-04T13:12:21",
"upload_time_iso_8601": "2024-09-04T13:12:21.325397Z",
"url": "https://files.pythonhosted.org/packages/36/7b/8829299185f535ba49e84f46317e36006ff4be54572d2e27d249ebf33632/tcpw_armv7l-0.1.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 13:12:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jackcvr",
"github_project": "tcpw#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tcpw-armv7l"
}