-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't populate database via sh script #603
Comments
If you can't modify it to use a unix socket then perhaps you could continually re-run your script for a duration of time so when the server eventually initializes it will then connect. Or you could try a sleep to run the script after a wait period. The PR for the rationale behind this change #440 |
actually we have 10 tries in the script but it doesn't work anywhere
I'm using the following bash script
|
So your first check returned an
That means it connected successfully, however your script requires two successful connections. And in the second one you get an error with an root@42d533e02f21:/# psql --host=localhost --port=5432 -l
psql: FATAL: role "root" does not exist
root@42d533e02f21:/# echo $?
2 If instead you change that to authenticate as a valid user in the database then it resolves (by default localhost connections using root@42d533e02f21:/# psql --host=localhost -U postgres --port=5432 -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access
privileges
-----------+----------+----------+------------+------------+----------
. . .
root@42d533e02f21:/# echo $?
0 However you can't use /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/script.sh
+ init
+ attempt_number=0
+ waitForPostgreSQL
+ psql --host=localhost --port=5432 --version
+ check1_result=0
+ psql -U postgres --host /var/run/postgresql --port=5432 -l
PostgreSQL is ready.
+ check2_result=0
+ [[ 0 -eq 0 ]]
+ [[ 0 -eq 0 ]]
+ return 0
+ echo 'PostgreSQL is ready.'
2019-07-30 17:42:07.108 UTC [43] LOG: received fast shutdown request
waiting for server to shut down....2019-07-30 17:42:07.146 UTC [43] LOG: aborting any active transactions
2019-07-30 17:42:07.151 UTC [43] LOG: background worker "logical replication launcher" (PID 50) exited with exit code 1
2019-07-30 17:42:07.151 UTC [45] LOG: shutting down
2019-07-30 17:42:07.796 UTC [43] LOG: database system is shut down
done
server stopped
PostgreSQL init process complete; ready for start up.
2019-07-30 17:42:07.885 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-07-30 17:42:07.885 UTC [1] LOG: listening on IPv6 address "::", port 5432
2019-07-30 17:42:07.977 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-07-30 17:42:08.472 UTC [70] LOG: database system was shut down at 2019-07-30 17:42:07 UTC
2019-07-30 17:42:08.526 UTC [1] LOG: database system is ready to accept connections You might also be interested in the healthcheck examples if that's what you're going for |
Unfortunately doesn't work for me
probably because I changed default postgresql user via -e POSTGRES_USER=myOwnUserName |
Yeah you'll want Going to close since this isn't an issue with the image |
Have faced with the issue that our sh script doesn't work anymore. it worked until 9.6.8
As far as I have understood the root of the issue is
Our script has the following check
In the console I get the following error
I there any workaround? Unfortunately I can't update the script
The text was updated successfully, but these errors were encountered: