From 5a01dac7b9a64e028f2f95c632bd07d363c4a110 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Tue, 2 May 2006 23:52:50 +0000 Subject: [PATCH] - fix an intermittent startup problem: the only way we can be really sure that postgres is up, is by trying to access it --- plc.d/postgresql | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plc.d/postgresql b/plc.d/postgresql index 9095828..d868545 100755 --- a/plc.d/postgresql +++ b/plc.d/postgresql @@ -7,7 +7,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: postgresql,v 1.1 2006/04/06 21:51:59 mlhuang Exp $ +# $Id: postgresql,v 1.2 2006/04/25 21:18:19 mlhuang Exp $ # # Source function library and configuration @@ -25,8 +25,19 @@ export PGPORT=$PLC_DB_PORT # /etc/init.d/postgresql always returns 0, even on failure postgresql_start () { + # start() always returns 0 service postgresql start - status postmaster && [ -f /var/lock/subsys/postgresql ] + + # status() will still return 0 even while still initializing + if status postmaster && [ -f /var/lock/subsys/postgresql ] ; then + # The only way we can be sure is if we can access it + for i in $(seq 1 10) ; do + psql -U postgres -c "" template1 && return 0 + sleep 1 + done + fi + + return 1 } case "$1" in -- 2.47.0