Thread: pg_ctl -w start does not know that it has started postmaster

pg_ctl -w start does not know that it has started postmaster

From
Aaron Hillegass
Date:
Your name        :    Aaron Hillegass
Your email address    :      aaron@bignerdranch.com


System Configuration
---------------------
   Architecture (example: Intel Pentium)      : PPC

   Operating System (example: Linux 2.4.18) :  Mac OS X 10.3.5

   PostgreSQL version (example: PostgreSQL-8.0):   PostgreSQL-8.0b4

   Compiler used (example:  gcc 2.95.2)        :  gcc version 3.3 20030304
(Apple Computer, Inc. build 1666)


Please enter a FULL description of your problem:
------------------------------------------------

I have a script that must start the postmaster before continuing, so I
do this:

 > sudo -u postgres /Library/PostgreSQL/bin/pg_ctl -w start

But this always fails:

 > sudo -u postgres /Library/PostgreSQL/bin/pg_ctl -w start
waiting for postmaster to
start...............................................................coul
d not start postmaster

But the postmaster is actually started:

 > /Library/PostgreSQL/bin/psql -Unopali template1
Welcome to psql 8.0.0beta4, the PostgreSQL interactive terminal.

template1=#

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

Note that the process's user name (postgres) is different from the
database's owner (nopali).


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

I suspect that the problem is that when I did initdb,  I used 'nopali'
as the username, but pg_ctl is being run as 'postgres'.  Because there
is no database user called 'postgres', I think that this line in
pg_ctl.c always fails:

        if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,

"template1", NULL, NULL)) != NULL &&
                         (PQstatus(conn) == CONNECTION_OK ||
                          (strcmp(PQerrorMessage(conn),
                                          PQnoPasswordSupplied) == 0)))

Re: pg_ctl -w start does not know that it has started postmaster

From
Tom Lane
Date:
Aaron Hillegass <aaron@bignerdranch.com> writes:
> I have a script that must start the postmaster before continuing, so I
> do this:

> sudo -u postgres /Library/PostgreSQL/bin/pg_ctl -w start

This is not going to work very well because sudo doesn't update the
environment --- for example if PGUSER is set in your environment then
that's the username pg_ctl will try to use to connect with.  Perhaps
try

sudo su -l postgres -c '/Library/PostgreSQL/bin/pg_ctl -w start'

            regards, tom lane