Skip to content

Commit

Permalink
DEPLOY-22 Watch pg bouncer config files inside container
Browse files Browse the repository at this point in the history
  • Loading branch information
zlepper committed Oct 17, 2023
1 parent 35bc91d commit c9af54d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN \
# security
apk add -U --no-cache --upgrade busybox && \
# Download
apk add -U --no-cache autoconf autoconf-doc automake udns udns-dev curl gcc libc-dev libevent libevent-dev libtool make openssl-dev pkgconfig postgresql-client && \
apk add -U --no-cache inotify-tools autoconf autoconf-doc automake udns udns-dev curl gcc libc-dev libevent libevent-dev libtool make openssl-dev pkgconfig postgresql-client && \
curl -o /tmp/pgbouncer-$VERSION.tar.gz -L https://pgbouncer.github.io/downloads/files/$VERSION/pgbouncer-$VERSION.tar.gz && \
cd /tmp && \
# Unpack, compile
Expand All @@ -27,6 +27,8 @@ RUN \
rm -rf /tmp/pgbouncer* && \
apk del --purge autoconf autoconf-doc automake udns-dev curl gcc libc-dev libevent-dev libtool make openssl-dev pkgconfig

ADD run-pg-bouncer.sh /usr/bin/

USER postgres
EXPOSE 5432
CMD ["/usr/bin/pgbouncer", "/etc/pgbouncer/pgbouncer.ini"]
ENTRYPOINT ["/usr/bin/run-pg-bouncer.sh"]
14 changes: 14 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/sh

/usr/bin/pgbouncer /etc/pgbouncer/pgbouncer.ini &
PG_BOUNCER_PID=$!

{
inotifywait -r -m -e modify /etc/pgbouncer |
while read file_path file_event file_name; do
echo ${file_path}${file_name} event: ${file_event}
kill -1 $PG_BOUNCER_PID
done
} &
fg $PG_BOUNCER_PID

0 comments on commit c9af54d

Please sign in to comment.