Re: Question on start server using PG_CTL - Mailing list pgsql-admin

From Tom Lane
Subject Re: Question on start server using PG_CTL
Date
Msg-id 18222.1249314596@sss.pgh.pa.us
Whole thread Raw
In response to Question on start server using PG_CTL  ("Mark Steben" <msteben@autorevenue.com>)
List pgsql-admin
"Mark Steben" <msteben@autorevenue.com> writes:
> Is it possible that, during startup, postmaster.pid takes a second or two to
> be created and hadn't been created yet when the test was run?

It's not instantaneous, for sure.  For one thing, the kernel could be
scheduling the postmaster at lower priority than the continued execution
of your startup script.  If you don't have any sleep at all in there
then the risk of failure would be quite high, even assuming the
postmaster would create the pidfile instantaneously once it gets to run.
And there are other things it has to do first, like read the config file
so it knows where the data directory is ...

Since you say you're using pg_ctl, why don't you use its -w option and
not let the script proceed until you know the postmaster is up?

            regards, tom lane

pgsql-admin by date:

Previous
From: "Mark Steben"
Date:
Subject: Question on start server using PG_CTL
Next
From: Scott Marlowe
Date:
Subject: Re: Postgres has stopped listening on port 5432...