Skip to content

Commit

Permalink
Fix ssl.SSLError: [SSL: HTTP_REQUEST] http request (_ssl.c:997) in Sp…
Browse files Browse the repository at this point in the history
…ilo 3.0-p1
  • Loading branch information
sasadangelo committed Aug 29, 2023
1 parent 41c888c commit ed9b3f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion postgres-appliance/runit/pgqd/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if ! $CHPST true 2> /dev/null; then
fi

exec 2>&1
exec $CHPST env -i PGAPPNAME="pgq ticker" /scripts/patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini
exec $CHPST env -i PGAPPNAME="pgq ticker" SSL_RESTAPI_CERTIFICATE_FILE="$SSL_RESTAPI_CERTIFICATE_FILE" SSL_RESTAPI_PRIVATE_KEY_FILE="$SSL_RESTAPI_PRIVATE_KEY_FILE" SSL_RESTAPI_CA_FILE="$SSL_RESTAPI_CA_FILE" /scripts/patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini
27 changes: 25 additions & 2 deletions postgres-appliance/scripts/patroni_wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,31 @@ done
if [ $# -gt 0 ]; then
[ -n "$TIMEOUT" ] && CUTOFF=$(($(date +%s)+TIMEOUT))

while [ "$(curl -so /dev/null -w '%{http_code}' "http://localhost:8008/$ROLE")" != "200" ]; do
[ -n "$TIMEOUT" ] && [ $CUTOFF -le "$(date +%s)" ] && exit 2
PORT=8008
if [ -n "$APIPORT" ]
then
PORT="$APIPORT"
fi

options=""
protocol="http"

# If Patroni is configured in SSL we need to query the Patroni REST API using the
# HTTPS protocol and certificates.
if [ "$SSL_RESTAPI_CERTIFICATE_FILE" != "" ] && [ "$SSL_RESTAPI_PRIVATE_KEY_FILE" != "" ]
then
protocol="https"
options="$options --cert $SSL_RESTAPI_CERTIFICATE_FILE --key $SSL_RESTAPI_PRIVATE_KEY_FILE"
fi

if [ "$SSL_RESTAPI_CA_FILE" != "" ]
then
protocol="https"
options="$options --cacert $SSL_RESTAPI_CA_FILE"
fi

while [ "$(curl -so /dev/null -w '%{http_code}' $options "$protocol://localhost:$PORT/$ROLE")" != "200" ]; do
[ -n "$TIMEOUT" ] && [ "$CUTOFF" -le "$(date +%s)" ] && exit 2
sleep "$INTERVAL"
done

Expand Down

0 comments on commit ed9b3f2

Please sign in to comment.