Shell script to determine if PostgreSQL is accepting connections?
От | Jeff Ross |
---|---|
Тема | Shell script to determine if PostgreSQL is accepting connections? |
Дата | |
Msg-id | 45FD6C76.7050906@wykids.org обсуждение исходный текст |
Ответы |
Re: Shell script to determine if PostgreSQL is accepting connections?
|
Список | 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.
В списке pgsql-general по дате отправления: