Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Best way to refresh pgpass variable, does postgrest reloads the config? #1863

Closed
raamheineken opened this issue Jun 7, 2021 · 1 comment
Closed
Labels

Comments

@raamheineken
Copy link

I am connecting the postgrest server to postgresql running on azure using a managed identity.

it looks something like this:

#!/bin/bash

export API_VERSION="2019-08-01"
export RESOURCE="https://ossrdbms-aad.database.windows.net"
export CLIENT_ID="[SECRET]"
export SERVER_ADDRESS="[SECRET]"
export MI_USER="[SECRET]"
export JWT_TOKEN="[SECRET]"
export SCHEMA="test_schema"
export DBNAME="test"
export PGPASS=`curl -s "$IDENTITY_ENDPOINT?api-version=$API_VERSION&resource=$RESOURCE&client_id=$CLIENT_ID" -H X-IDENTITY-HEADER:$IDENTITY_HEADER | jq -r .access_token`

TMPFILE=$(mktemp).json

jq -n \
  --arg user $MI_USER \
  --arg pass $PGPASS \
  --arg server $SERVER_ADDRESS \
  --arg jwt $JWT_TOKEN \
  --arg pg_schema $SCHEMA \
  --arg dbname $DBNAME \
  '{
    user: $user, 
    password: $pass, 
    server: $server, 
    jwt: $jwt, 
    schema: $pg_schema,
    dbname: $dbname
  }' >> $TMPFILE

jinja -d $TMPFILE template_config.j2 >> result.conf

/app/binary/postgrestv7.0.1 ./result.conf

the token expires with out notice (the one obtained in the curl command on PGPASS env var).
Originally i was hoping to crash the docker container and by reloading PGPASS will get updated but i did not find any easy way to crash the server upon: {"message":"Database connection lost, retrying the connection."}%

i can regenerate the result.conf file but will it be re-read at some point?

thanks,

@wolfgangwalther
Copy link
Member

Using one of the nightly builds you can send a SIGUSR2 signal to the process to make it reload the config. This was merged in #1544, but has not been released, yet.

@PostgREST PostgREST locked and limited conversation to collaborators Jun 7, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Development

No branches or pull requests

2 participants