Thread: Postgres and Upstart

Postgres and Upstart

From
Chris Angelico
Date:
We run a multi-node replication setup with an in-house monitoring
program that decides when to promote a slave, etc, etc. Everything is
managed through Upstart.

I'm looking for a reliable way to be sure that Postgres has finished
its initialization and is ready to rumble. Especially, I don't want to
SIGHUP the server before it's hooked the signal! (My logs show
repeated "server killed by HUP" messages. Amusing perhaps, but not
very helpful.)

Would it be possible to have a configuration entry to have postmaster
SIGSTOP itself as soon as, but no sooner than, it's fully ready?
Upstart can recognize this signal (and will promptly SIGCONT it), and
use it as an indication of readiness (the "expect stop" stanza).

Or maybe it already exists in some other form and I haven't seen it,
in which case all I'm asking is: How best can this be done?

Chris Angelico

Re: Postgres and Upstart

From
"Albe Laurenz"
Date:
Chris Angelico wrote:
> I'm looking for a reliable way to be sure that Postgres has finished
> its initialization and is ready to rumble.

The normal way to test this is a connection attempt.
You could also look into the server logs for the
appropriate message, but that seems more fragile and difficult.

Does that help?

Yours,
Laurenz Albe