postgresql-action
postgresql-action copied to clipboard
Wait until server is fully started
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 As a temporary solution, I've changed the CI steps sequence: DB Setup - install dependencies - a step that uses DB.
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?
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)
Thanks @MarkKremer! Docker logs collecter is something I didn' knew. Thanks for that as well! :)
@pashagolub Did you figure this out? I'm having a similar issue.
@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