kumquat-buildroot/package/postgresql/S50postgresql
Floris Bos e7d515d00e postgresql: init script: wait till server has started
Adds "-w" option to init script to wait till the database server
has fully started and accepts connections before continuing.

Prevents other applications that depend on PostgreSQL from
failing to start, if the database server is not ready yet.
Times out after 60 seconds by default.

Signed-off-by: Floris Bos <bos@je-eigen-domein.nl>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-07-11 09:27:38 +02:00

45 lines
644 B
Bash

#!/bin/sh
#
# start postgresql
#
umask 077
if [ ! -f /var/lib/pgsql/PG_VERSION ]; then
echo "Initializing postgresql data base..."
su - postgres -c '/usr/bin/pg_ctl initdb -D /var/lib/pgsql'
echo "done"
fi
start() {
echo -n "Starting postgresql: "
su - postgres -c '/usr/bin/pg_ctl start -w -D /var/lib/pgsql -l logfile'
echo "OK"
}
stop() {
echo -n "Stopping postgresql: "
su - postgres -c '/usr/bin/pg_ctl stop -D /var/lib/pgsql -m fast'
echo "OK"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?