I was looking into several ideas that all have some problems.

0. Look into pg_settings

Doesn't work because we can only query the database if we already know
the port

1. Put the port on the postgres command line (postgres -p 5555)

Works, but then restarting the server is hard once the port got
changed. `pg_ctl restart` will even preserve the last command line.

2. Put the port into a file next to /var/run/postgresql/11-main.pid

Has several consistency issues. If the port is changed, the file is
not updated immediately. If the cluster is shut down, should the file
be removed?

3. Write a suid wrapper that read postgresql.auto.conf

suid programs are a security nightmare.

4. Patch PostgreSQL such that it puts the port into external_pid_file,
i.e. into /var/run/postgresql/11-main.pid

Patching the server is evil, and it breaks applications reading the
external file that are not prepared to ignore extra information


The bottom line is that #4 looks most attractive, but I'm not fixing
this in postgresql-common now. I will try sending a patch for #4 to
upstream and see if it gets accepted for PG 12+. If so, we can still
patch the older versions on our side.

Christoph

Reply via email to