HackerTrans
TopNewTrendsCommentsPastAskShowJobs

stavepan

no profile record

Submissions

Sq.io: jq for databases and more

sq.io
606 points·by stavepan·vor 2 Jahren·129 comments

OpenAI released Whisper large-v3-turbo model

github.com
5 points·by stavepan·vor 2 Jahren·0 comments

Elon Musk's XAI Raises $6B in Latest Funding Round

forbes.com
2 points·by stavepan·vor 2 Jahren·0 comments

Show HN: Is_ready – Wait for many services to become available – 0 Dependencies

github.com
38 points·by stavepan·vor 2 Jahren·40 comments

comments

stavepan
·vor 2 Jahren·discuss
Healthchecks are a great way to achieve this.

As this repository mentions, this is the example using PostgreSQL.

depends_on: postgres-database: condition: service_healthy

healthcheck: test: ["CMD-SHELL", "pg_isready"] interval: 10s timeout: 5s retries: 5

However, PostgreSQL has already a command for this called pg_isready.

How is this going to work for other cases such as MySQL?
stavepan
·vor 2 Jahren·discuss
Many people have the following setup in docker-compose.yml file.

version: '3' services: mysql: image: mysql:8.0

  app:
    build: .
    command: is_ready --timeout 10 --addr mysql:3306 -- <run migrations command>
For cases like this, returning 503 every time the database is not ready, is not very convenient.
stavepan
·vor 2 Jahren·discuss
To be honest, I wanted to make the title more specific regarding dependencies but the title was already too big.
stavepan
·vor 2 Jahren·discuss
That's true.

For example, in the case of PostgreSQL, there is already a tool called pg_isready [0] to do this inside a healthcheck as you described.

services: postgres-db: image: postgres healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"]

  application:
    image: image
    depends_on:
      postgres-db:
        condition: service_healthy
However, this is not the case for other databases/services.

[0] https://www.postgresql.org/docs/current/app-pg-isready.html
stavepan
·vor 2 Jahren·discuss
Can you suggest to me one way for an API service to wait for a database to accept connections to run the database migrations without the API depending on the liveness of the database to start up?
stavepan
·vor 2 Jahren·discuss
Interesting idea for a feature request. I would love to read a GitHub issue with your specific case so I can start investigating and think about how to solve a problem like this.
stavepan
·vor 2 Jahren·discuss
Interesting project, I was not familiar with that. Thanks for letting me know :)
stavepan
·vor 2 Jahren·discuss
Regarding zero dependencies, I meant that it is a static binary and does not need any external tools to be installed. For example, some alternatives require netcat to be installed.
stavepan
·vor 2 Jahren·discuss
is_ready is an alternative to this.

I built it for many reasons: - Most docker images do not contain netcat so you would have to download one of them in any case. - In the case of is_ready, you won't have to write this script yourself. - Repositories like this had a lot of traffic so I supposed that engineers need a similar tool but this repository requires wget and netcat as dependencies. For this reason, I built my own without any dependencies. https://github.com/eficode/wait-for