From: | Jeff Ross <jross(at)wykids(dot)org> |
---|---|
To: | pgsql general <pgsql-general(at)postgresql(dot)org> |
Subject: | Shell script to determine if PostgreSQL is accepting connections? |
Date: | 2007-03-18 16:44:38 |
Message-ID: | 45FD6C76.7050906@wykids.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
Is there a simple way to determine with a shell script if PostgreSQL is
ready to accept connections?
PostgreSQL is started and controlled by daemontools. This shell script
is called by the /etc/netstart script as a part of bringing up the
first interface. Unfortunately, it will never exit the loop.
#!/bin/sh
/bin/csh -cf '/command/svscanboot &'
until [ -S /tmp/.s.PGSQL.5432 ] ; do
/bin/echo "Waiting for PostgreSQL to start..."
/bin/sleep 1
done
Because this is happening at startup before I get a login prompt I'm not
sure I know how to figure out why it never exits the loop.
The purpose of this is that I'm running pglogd, a daemon that uses a
custom log format and a fifo to stuff Apache web logs into a table. The
pglogd daemon must start after PostgreSQL and before Apache. I can do
this in /etc/rc.local, but OpenBSD's /etc/rc wants to start Apache
before rc.local is parsed. Once I know that PostgreSQL is up and
accepting connections I can then start pglogd and then it's ready to go
when Apache starts.
As a side note, the original creator and maintainer of pglogd has EOLed
the project but it works well for me under 8.2.3. I intend to fix a few
of its problems (it does fine until the backend goes away ;-) and
re-release it.
Thanks,
Jeff Ross
P.S. Apologies to the owner of the list--I inadvertently sent this to
the wrong address first.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-03-18 16:47:09 | Re: Is This A Set Based Solution? |
Previous Message | Bob Hartung | 2007-03-18 16:41:47 | phpPgAdmin - prior version available? |