postgresql-action icon indicating copy to clipboard operation
postgresql-action copied to clipboard

Wait until server is fully started

Open MarkKremer opened this issue 5 years ago • 6 comments

I had some trouble connecting to the database immediately after this action. This resulted in a "connection reset by peer" error. Adding a sleep action between the actions solved it. However, it would be better if the postgresql action could wait the appropriate amount of time itself by pinging itself or something similar.

I think this would also solve https://github.com/Harmon758/postgresql-action/issues/6 but I'm not sure so therefor this separate issue.

MarkKremer avatar Feb 01 '20 19:02 MarkKremer

@MarkKremer As a temporary solution, I've changed the CI steps sequence: DB Setup - install dependencies - a step that uses DB.

ihorost avatar Feb 18 '20 10:02 ihorost

Guys, can you help me? I cannot make this to work. No way. I've tried a lot already and came with this, but no luck at all:

jobs:

  ubuntu-marketplace:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
    steps:
    - name: Setup PostgreSQL
      uses: Harmon758/[email protected]
      with:
        postgresql version: '11'
        postgresql db: 'postgres'
        postgresql user: 'postgres'
    - name: Check Postgres running
      run: |
        sleep 1m
        psql -U postgres -d postgres -h localhost -c "SELECT version()"

Output:

Check Postgres running
1m 1s
##[error]Process completed with exit code 2.
Run sleep 1m
  sleep 1m
  psql -U postgres -d postgres -h localhost -c "SELECT version()"
  shell: /bin/bash -e {0}
psql: could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?
##[error]Process completed with exit code 2.

What've I missed, @MarkKremer, @ihorost?

pashagolub avatar Mar 24 '20 17:03 pashagolub

I don't see anything wrong with that. This is what I used to debug my problem:

    - name: Wait / Sleep
      uses: jakejarvis/[email protected]
      with:
        time: '10s'
   
    - name: Collect Docker Logs
      uses: jwalton/[email protected]
   
    - name: Check running containers
      run: docker ps -a

(put it after the postgres action)

MarkKremer avatar Mar 25 '20 09:03 MarkKremer

Thanks @MarkKremer! Docker logs collecter is something I didn' knew. Thanks for that as well! :)

pashagolub avatar Mar 25 '20 09:03 pashagolub

@pashagolub Did you figure this out? I'm having a similar issue.

andrewDoing avatar Dec 15 '20 22:12 andrewDoing

@andrewDoing I did it differently since the worker's OS has PostgreSQL preinstalled. Check here: https://github.com/cybertec-postgresql/.github/blob/main/workflow-templates/postgresql-ubuntu.yml

pashagolub avatar Dec 16 '20 11:12 pashagolub