Commit e6de48d4 authored by Francesco Colista's avatar Francesco Colista

testing/pgbouncer: new aport. Fixes #6766

parent 57241d96
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=pgbouncer
pkgver=1.7.2
pkgrel=0
pkgdesc="A lightweight connection pooler for PostgreSQL"
url="https://wiki.postgresql.org/wiki/PgBouncer"
arch="all"
license="BSD"
pkgusers="pgbouncer"
pkggroups="postgres"
install="$pkgname.pre-install"
makedepends="c-ares-dev libevent-dev libressl-dev udns-dev"
subpackages="$pkgname-doc"
source="https://pgbouncer.github.io/downloads/files/$pkgver/$pkgname-$pkgver.tar.gz
$pkgname.initd
$pkgname.confd
$pkgname.logrotate
pgbouncer-dirs.patch"
builddir="$srcdir/$pkgname-$pkgver"
build() {
cd "$builddir"
./configure \
--prefix=/usr \
--disable-debug
make || return 1
}
package() {
cd "$builddir"
make DESTDIR="$pkgdir" install
mkdir -p "$pkgdir"/var/log/pgbouncer
chown $pkgusers:$pkggroups "$pkgdir"/var/log/pgbouncer
install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
install -m644 -D "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
install -m644 -D etc/$pkgname.ini "$pkgdir"/etc/$pkgname/$pkgname.ini
}
sha512sums="11c89606599f424b34f39a4b072ec6293fea0b14ee52ae4fbc44775e6d83771a22d194f4e8eabe410e0d6a70657508cf1a3b1012543d91873c36f644afb5675d pgbouncer-1.7.2.tar.gz
ecd34f017316b2c0aad172e5bf5393137da5ab841f4d6de93eb82a07abe9f234a2426ca7dada2dc047c33ea4c7dc0af3040b249ec1f9d7e0c1782fb0463a7293 pgbouncer.initd
dbcd7f5860b7f1ec6b6372b718678ba74c5268e89eed0fe291cd292a50460f0e81876367cb86e97f1cfefc0ace8d698c41a313642ec64d2de0747c348665afba pgbouncer.confd
5aa4226ab2d168a88a3b64deb114d3901431d2afb2571cf8ae411c989549bc465ee05104a6863cc8fce6d769d809b4ab536973280f50cb4415c6698c34e1a5b8 pgbouncer.logrotate
6a475bf5cff10b464177af619051529ad78e802c56655500ad23130c5989721f41592387f9bf6719810eae2d876a8dd36219b87ae1fdb29304b2adc98c49ae4c pgbouncer-dirs.patch"
diff -Naruw a/etc/pgbouncer.ini b/etc/pgbouncer.ini
--- a/etc/pgbouncer.ini 2012-06-10 19:57:01.000000000 +0000
+++ b/etc/pgbouncer.ini 2013-07-17 02:25:59.598888628 +0000
@@ -29,7 +29,7 @@
;;;
logfile = /var/log/pgbouncer/pgbouncer.log
-pidfile = /var/run/pgbouncer/pgbouncer.pid
+pidfile = /run/pgbouncer/pgbouncer.pid
;;;
;;; Where to wait for clients
@@ -40,10 +40,9 @@
listen_port = 6432
; unix socket is also used for -R.
-; On debian it should be /var/run/postgresql
-;unix_socket_dir = /tmp
-;unix_socket_mode = 0777
-;unix_socket_group =
+unix_socket_dir = /run/postgresql
+unix_socket_mode = 0777
+unix_socket_group = postgres
;;;
;;; Authentication settings
# Location of configuration file for PgBouncer.
INIFILE="/etc/pgbouncer/pgbouncer.ini"
# How long to wait in seconds for a safe shutdown. Equivalent to
# issuing 'PAUSE;' and 'SHUTDOWN;' on psql console. (See 'man 1 pgbouncer'.)
NICE_TIMEOUT=60
# Set to 'YES' to perform an immediate shutdown if the nice shutdown
# doesn't work. Same as issuing 'SHUTDOWN;' on console. (See 'man 1
# pgbouncer'.)
FORCE_QUIT="no"
FORCE_QUIT_TIMEOUT=2
#!/sbin/openrc-run
extra_started_commands="reload"
depend() {
use net
after postgresql
}
get_config() {
[ -f "${INIFILE}" ] || eend 1 "'${INIFILE}' not found"
eval echo $(sed -e 's:;.*::' "${INIFILE}" | \
awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
}
PIDFILE="$(get_config pidfile)"
UNIX_SOCKET_DIR="$(get_config unix_socket_dir)"
prep() {
if [ -n "${UNIX_SOCKET_DIR}" ] ; then
checkpath -o postgres:postgres -m 0775 -d "${UNIX_SOCKET_DIR}" \
|| return 1
fi
checkpath -o pgbouncer:postgres -m 0755 -d "$(dirname ${PIDFILE})" \
|| return 1
checkpath -o pgbouncer:postgres -m 0644 -f "${PIDFILE}" \
|| return 1
checkpath -o pgbouncer:postgres -m 0755 -d "$(dirname $(get_config logfile))" \
|| return 1
checkpath -o pgbouncer:postgres -m 0640 -f "$(get_config logfile)" \
|| return 1
return 0
}
start() {
ebegin "Starting PgBouncer"
prep
local ret=$?
if [ $ret -ne 0 ] ; then
eend $ret
exit $ret
fi
start-stop-daemon --start \
--pidfile ${PIDFILE} \
--user pgbouncer \
--exec /usr/bin/pgbouncer -- -q -d "${INIFILE}"
eend $?
}
stop() {
local seconds=$(( ${NICE_TIMEOUT} + ${FORCE_QUIT_TIMEOUT} ))
ebegin "Stopping PgBouncer (this can take up to ${seconds} seconds)"
local retries=SIGINT/${NICE_TIMEOUT}
if [ "${FORCE_QUIT}" = "YES" ] ; then
einfo "FORCE_QUIT enabled."
retries="${retries}/SIGTERM/${FORCE_QUIT_TIMEOUT}"
fi
# Loops through nice and force quit in one go.
start-stop-daemon --stop \
--pidfile ${PIDFILE} \
--retry ${retries}
eend $?
}
restart() {
if [ -n "${UNIX_SOCKET_DIR}" ] ; then
ebegin "Performing online restart of PgBouncer"
start-stop-daemon --start \
--pidfile ${PIDFILE} \
--user pgbouncer \
--exec /usr/bin/pgbouncer -- -q -d -R "${INIFILE}"
eend $?
else
stop && start
fi
}
reload() {
ebegin "Reloading PgBouncer configuration from '${INIFILE}'"
start-stop-daemon --signal HUP --pidfile ${PIDFILE}
eend $?
}
/var/log/pgbouncer/pgbouncer.log {
missingok
sharedscripts
postrotate
/etc/init.d/pgbouncer -q reload
endscript
}
\ No newline at end of file
#!/bin/sh
adduser -S -D -H -h /dev/null -s /sbin/nologin -G postgres -g pgbouncer pgbouncer 2>/dev/null
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment