aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorFrancesco Colista <fcolista@alpinelinux.org>2017-02-20 11:27:11 +0000
committerFrancesco Colista <fcolista@alpinelinux.org>2017-02-20 11:27:17 +0000
commite6de48d4857379d7e1d83c13a661503dd47fda0a (patch)
tree2e11e2692633604d64034a25c3f722750e864c6e /testing
parent57241d9646f1db85174c810c86fe40b5daa1e65f (diff)
downloadaports-e6de48d4857379d7e1d83c13a661503dd47fda0a.tar.gz
aports-e6de48d4857379d7e1d83c13a661503dd47fda0a.tar.bz2
aports-e6de48d4857379d7e1d83c13a661503dd47fda0a.tar.xz
testing/pgbouncer: new aport. Fixes #6766
Diffstat (limited to 'testing')
-rw-r--r--testing/pgbouncer/APKBUILD45
-rw-r--r--testing/pgbouncer/pgbouncer-dirs.patch26
-rw-r--r--testing/pgbouncer/pgbouncer.confd12
-rw-r--r--testing/pgbouncer/pgbouncer.initd88
-rw-r--r--testing/pgbouncer/pgbouncer.logrotate7
-rw-r--r--testing/pgbouncer/pgbouncer.pre-install3
6 files changed, 181 insertions, 0 deletions
diff --git a/testing/pgbouncer/APKBUILD b/testing/pgbouncer/APKBUILD
new file mode 100644
index 0000000000..38af308884
--- /dev/null
+++ b/testing/pgbouncer/APKBUILD
@@ -0,0 +1,45 @@
+# 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 --git a/testing/pgbouncer/pgbouncer-dirs.patch b/testing/pgbouncer/pgbouncer-dirs.patch
new file mode 100644
index 0000000000..62bcd0b844
--- /dev/null
+++ b/testing/pgbouncer/pgbouncer-dirs.patch
@@ -0,0 +1,26 @@
+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
diff --git a/testing/pgbouncer/pgbouncer.confd b/testing/pgbouncer/pgbouncer.confd
new file mode 100644
index 0000000000..84961a83c9
--- /dev/null
+++ b/testing/pgbouncer/pgbouncer.confd
@@ -0,0 +1,12 @@
+# 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
diff --git a/testing/pgbouncer/pgbouncer.initd b/testing/pgbouncer/pgbouncer.initd
new file mode 100644
index 0000000000..20479dc22d
--- /dev/null
+++ b/testing/pgbouncer/pgbouncer.initd
@@ -0,0 +1,88 @@
+#!/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 $?
+}
diff --git a/testing/pgbouncer/pgbouncer.logrotate b/testing/pgbouncer/pgbouncer.logrotate
new file mode 100644
index 0000000000..9617eafa66
--- /dev/null
+++ b/testing/pgbouncer/pgbouncer.logrotate
@@ -0,0 +1,7 @@
+/var/log/pgbouncer/pgbouncer.log {
+ missingok
+ sharedscripts
+ postrotate
+ /etc/init.d/pgbouncer -q reload
+ endscript
+} \ No newline at end of file
diff --git a/testing/pgbouncer/pgbouncer.pre-install b/testing/pgbouncer/pgbouncer.pre-install
new file mode 100644
index 0000000000..609b3a9272
--- /dev/null
+++ b/testing/pgbouncer/pgbouncer.pre-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+adduser -S -D -H -h /dev/null -s /sbin/nologin -G postgres -g pgbouncer pgbouncer 2>/dev/null
+exit 0