diff options
Diffstat (limited to 'dev-db/pgbouncer/files/pgbouncer.initd')
-rw-r--r-- | dev-db/pgbouncer/files/pgbouncer.initd | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/dev-db/pgbouncer/files/pgbouncer.initd b/dev-db/pgbouncer/files/pgbouncer.initd new file mode 100644 index 000000000..c2cdabf27 --- /dev/null +++ b/dev-db/pgbouncer/files/pgbouncer.initd @@ -0,0 +1,45 @@ +#!/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 pgbouncer user" + +# 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 pgbouncer /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 +} |