#!/sbin/runscript # pgbouncer Start the PgBouncer PostgreSQL pooler opts="start stop reload checkconfig" depend() { need net after postgresql } checkconfig(){ test -f /etc/pgbouncer.conf result=$? eend $result } start() { checkconfig || return 1 ebegin "Starting pgbouncer as Postgres" if [ -f "/var/run/postgresql/pgbouncer.pid" ] ; then rm -f "/var/run/postgresql/pgbouncer.pid" fi PIDFILE="/var/run/postgresql/pgbouncer.pid" TIMEOUT=${TIMEOUT:-10} PGBOUNCER_OPTS="-d -u postgres /etc/pgbouncer.conf" /usr/bin/pgbouncer ${PGBOUNCER_OPTS} let i=0 while [ ! -e "${PIDFILE}" ] && [ $i -lt ${TIMEOUT} ]; do sleep 1 && i=$(expr $i + 1) done test $i -le ${TIMEOUT} eend $? } stop() { ebegin "Stopping pgbouncer" start-stop-daemon --stop --quiet --pidfile /var/run/postgresql/pgbouncer.pid eend $? } reload() { ebegin "Reloading pgbouncer configuration" start-stop-daemon --stop --pidfile /var/run/postgresql/pgbouncer.pid --signal HUP }