Thread: moving postgresql.conf: pg_ctl can't find postmaster.pid anymore

moving postgresql.conf: pg_ctl can't find postmaster.pid anymore

From
Ludo Smissaert
Date:
Hi,

The Postgresql configuration files can be kept elsewhere than the data
directory, as is described in the section about "File Locations."
(18.2 of as of 8.4)[1]

The documentation here basically mentions two ways of doing this.

First you can start Postgresql with the -D option to pg_ctl pointing to
the configuration files(/etc/postgresql for example), and then specify
the data cluster directory (/var/postgresql/data for example) inside
postgresql.conf.

$ pg_ctl -D /etc/postgresql -l .../logfile start

The second way is starting postgresql with the `config_file` parameter
passed to the postgres process via the -c option of the postgres
command, then specify each file individually inside postgresql.conf.

$ pg_ctl -o "-c config_file='/etc/postgresql/postgresql.conf'" \
    -l .../logfile  start

Both methods works fine on server startup, but the first method gives
problems when stopping the server with pg_ctl.

The problem I found is that pg_ctl expected the file 'postmaster.pid'
inside the configuration directory passed to with -D (/etc/postgresql),
but postgres created it in the data cluster directory as specified
inside postgresql.conf (/var/postgresql/data).

I could fake pg_ctl with -D pointing to the data cluster
directory, not to the configuration directory. Then it worked fine. But
I feel this is not the right way of doing things.

As I understand, `external_pid_file`, has nothing to do with this: it is
an *extra* pid file, not the one needed by pg_ctl.

Any comments on this are very welcome.

Thank you all and have a very nice day/night :)

Ludo

--
[1]
http://www.postgresql.org/docs/8.4/static/runtime-config-file-locations.html

Re: moving postgresql.conf: pg_ctl can't find postmaster.pid anymore

From
Tom Lane
Date:
Ludo Smissaert <ludo@ludikidee.com> writes:
> Both methods works fine on server startup, but the first method gives
> problems when stopping the server with pg_ctl.

Yeah, pg_ctl is far too stupid to cope with such things --- it expects
that PGDATA points at the data directory.  Short of teaching it to parse
the config file it's not clear what we could do about that.

            regards, tom lane

Re: moving postgresql.conf: pg_ctl can't find postmaster.pid anymore

From
Ludo Smissaert
Date:
Tom Lane wrote:
> Ludo Smissaert <ludo@ludikidee.com> writes:
>> Both methods works fine on server startup, but the first method gives
>> problems when stopping the server with pg_ctl.
>
> Yeah, pg_ctl is far too stupid to cope with such things --- it expects
> that PGDATA points at the data directory.  Short of teaching it to parse
> the config file it's not clear what we could do about that.

Thanks. Summarizing:

$ ls /etc/postgresql
postgresql.conf pg_hba.conf pg_ident.conf

$ pg_ctl -D /var/postgresql/data -o "-D /etc/postgresql" start -l ...

... server started

$ pg_ctl -D /var/postgresql/data -o "-D /etc/postgresql" stop -m fast

works for the first method, and for the second:

$ pg_ctl -D /var/postgresql/data/ \
   -o "-c config_file='/etc/postgresql/postgresql.conf'" -l ... start

and for stopping the same.

Have a nice day/night,

Ludo