Coder Social home page Coder Social logo

zubedev / r-u-ready Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 4 KB

./r-u-ready is a script that checks if psql/mysql db or even django/flask servers are ready for connection

License: MIT License

Shell 100.00%
mysql mysql-server postgresql postgresql-server django flask docker docker-compose dockerfile wait wait-for-it shell-script containers

r-u-ready's Introduction

r-u-ready to accept connections pgsql/mysql or any web service?

./r-u-ready is a script created to wait for services like pgsql/mysql/django/flask in docker containers. It was inspired by eficode/wait-for and vishnubob/wait-for-it.

When using this tool, you only need to pick the r-u-ready file as part of your project.

Usage

./r-u-ready service [-h host] [-P port] [-u username] [-p password] [-t timeout] [-- command args]

  service REQUIRED                    pgsql | mysql | web

  -h HOST | --host=HOST               Domain/IP host (default: 127.0.0.1)
  -P PORT | --port=PORT               Port (default: 5432 for psql, 3306 for mysql, 80 for web)

  -u USERNAME | --username=USERNAME   MySQL username (required for mysql only)
  -p PASSWORD | --password=PASSWORD   MySQL password for the given username (required for mysql only)

  -q | --quiet                        Do not output any status messages
  -t TIMEOUT | --timeout=TIMEOUT      Timeout in seconds, zero for no timeout (default: 15 seconds)
  -- COMMAND ARGS                     Execute command with args after the test finishes

Examples

To check if google.com is available:

$ ./r-u-ready web -h google.com -- echo "Google.com site is up"

Waiting for web server at google.com: to be ready...
web server at google.com: is ready for connection

Google.com site is up

To wait for mysql database to accept connections:

$ ./r-u-ready mysql -h 127.0.0.1 -P 3306 -u root -p <password> -t 300

Waiting for mysql server at 127.0.0.1:3306 to be ready...
mysql server at 127.0.0.1:3306 is ready for connection

To wait for database container to become available:

version: '3.7'

services:
  db:
    image: postgres:alpine

  backend:
    build: backend
    command: sh -c './r-u-ready pgsql -h db -t 60'
    depends_on:
      - db

Note

Make sure postgresql-client or mariadb-client or curl is installed in your Dockerfile before running the command.

RUN apk add --update curl
RUN apk add postgresql-client
RUN apk add mariadb-client

r-u-ready's People

Contributors

zubedev avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.