#!/sbin/runscript extra_started_commands="reload upgrade" if [ -d /run ] ; then RUNDIR=/run/pgbouncer else RUNDIR=/var/run/pgbouncer fi depend() { need net after postgresql } start() { mkdir -p ${RUNDIR} chown pgbouncer:pgbouncer ${RUNDIR} ebegin "Starting pgbouncer" start-stop-daemon --start --pidfile ${RUNDIR}/pgbouncer.pid \ --exec /usr/bin/pgbouncer -- -q -d -u pgbouncer /etc/pgbouncer.conf eend $? "Failed to start pgbouncer" } stop() { ebegin "Stopping pgbouncer" start-stop-daemon --stop --quiet --pidfile ${RUNDIR}/pgbouncer.pid eend $? } reload() { ebegin "Gracefully reloading pgbouncer" kill -HUP $(head -n1 ${RUNDIR}/pgbouncer.pid) eend $? } upgrade() { egrep -q "^unix_socket_dir" /etc/pgbouncer.conf || \ eerror "Not running with unix sockets, cannot upgrade" ebegin "Gracefully upgrading pgbouncer" /usr/bin/pgbouncer -R -q -d -u pgbouncer /etc/pgbouncer.conf eend $? }