{"id":24583508,"url":"https://github.com/parrotmac/awfi","last_synced_at":"2025-03-17T17:14:37.672Z","repository":{"id":244850161,"uuid":"816456711","full_name":"parrotmac/awfi","owner":"parrotmac","description":"Another Wait-For-It: Wait for Postgres \u0026 HTTP/S resources","archived":false,"fork":false,"pushed_at":"2024-06-17T19:53:08.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T04:46:39.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parrotmac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-17T19:45:59.000Z","updated_at":"2024-06-17T19:54:29.000Z","dependencies_parsed_at":"2024-06-19T02:44:35.561Z","dependency_job_id":null,"html_url":"https://github.com/parrotmac/awfi","commit_stats":null,"previous_names":["parrotmac/awfi"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrotmac%2Fawfi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrotmac%2Fawfi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrotmac%2Fawfi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parrotmac%2Fawfi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parrotmac","download_url":"https://codeload.github.com/parrotmac/awfi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244075636,"owners_count":20393979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-24T04:46:51.941Z","updated_at":"2025-03-17T17:14:37.648Z","avatar_url":"https://github.com/parrotmac.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# awfi - Another Wait-For-It Tool\n\n`awfi` is a simple tool to wait for a resource to become available. It supports\nboth HTTP and Postgres resources. Requests are retried every second until the\nresource becomes available or the timeout is reached. The default timeout is 10\nseconds.\n\nFor HTTP/HTTPS resources, the tool will wait for a 200 status code. For Postgres\nresources, the tool will wait for a successful connection and success when executing\nthe query \"SELECT 1\".\n\n## Installation\n\nCurrently, the only supported installation method is using `go install`:\n```bash\ngo install github.com/parrotmac/awfi@latest\n```\n\n## Usage\n\n```bash\nawfi [flags] \u003cresource\u003e\n```\n\n### Flags\n\n- `-t, --timeout`: The timeout in seconds. Default is 10 seconds.\n\n### Examples\n\nWait for a local Postgres database to become available:\n```bash\nawfi postgres://user:password@localhost:5432/dbname\n```\n\nWait for a remote HTTP resource to become available:\n```bash\nawfi https://example.com\n```\n\n## Why Another Wait-For-It Tool?\n\nWhile building out CI/CD pipelines, I found myself needing a simple tool to wait\nfor resources to become available. In particular, when waiting for a Postgres\ndatabase to become available, I would do copy-paste something like the following\nsnippet:\n\n```shell\ndid_start=false\n# shellcheck disable=SC2034\nfor i in {1..30}; do\n  if pg_isready -U \"$username\" -h \"$host\" -p \"$port\" -d \"$dbname\" -t 1; then\n    did_start=true\n    break\n  fi\n  printf \".\"\n  sleep 1\ndone\nprintf \"\\n\"\nif ! $did_start; then\n  echo \"Failed to start database\"\n  exit 1\nfi\n```\n\nHowever, in actual usage I'd find myself tweaking the script to add more features\nor cover the seemingly common edge case of the database being 'ready' while still\nbeing unable to accept connections:\n```shell\n Network cool_app_default  Creating\n Network cool_app_default  Created\n Container cool-app-db-1  Creating\n Container cool-app-db-1  Created\n Container cool-app-db-1  Starting\n Container cool-app-db-1  Started\n/var/run/postgresql:5432 - no response\n/var/run/postgresql:5432 - accepting connections\npsql: error: connection to server at \"localhost\" (::1), port 5432 failed: server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\n```\n\nSince I found myself tweaking the script and still running into issues, I decided\nto write a simple tool that would handle the most common cases and edge cases\nfor me.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparrotmac%2Fawfi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparrotmac%2Fawfi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparrotmac%2Fawfi/lists"}