Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 747160 - dev-db/pgbouncer : add systemd support
Summary: dev-db/pgbouncer : add systemd support
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PgSQL Bugs
Depends on:
Blocks: install-systemd-unit
  Show dependency tree
Reported: 2020-10-07 19:15 UTC by Vasilis Lourdas
Modified: 2020-10-13 12:18 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---

pgbouncer.service sample (pgbouncer.service,1.28 KB, text/x-dbus-service)
2020-10-09 15:54 UTC, Vasilis Lourdas
pgbouncer.service (pgbouncer.service,1.29 KB, text/x-dbus-service)
2020-10-11 06:15 UTC, Vasilis Lourdas
pgbouncer.socket (pgbouncer.socket,760 bytes, text/x-systemd-unit)
2020-10-11 06:15 UTC, Vasilis Lourdas
pgbouncer.service v.3 (pgbouncer.service,1.25 KB, text/x-dbus-service)
2020-10-13 12:18 UTC, Vasilis Lourdas

Note You need to log in before you can comment on or make changes to this bug.
Description Vasilis Lourdas 2020-10-07 19:15:47 UTC
pgbouncer 1.14 supports compilation with systemd support and includes a example service unit file. It would be nice to add systemd as USE flag for this ebuild for the systems that use systemd as their init system.

For more information look at this commit:

Thank you!
Comment 1 Vasilis Lourdas 2020-10-09 15:54:52 UTC
Created attachment 664474 [details]
pgbouncer.service sample

Here's my pgbouncer.service file that worked for my case.
Comment 2 Aaron W. Swenson gentoo-dev 2020-10-10 11:31:05 UTC
Let me first state I have neither the time nor the interest to learn about systemd. I use OpenRC, and it would not benefit me to waste my time on it. This also mean I don't know enough to truly advise how to best approach any desired outcome using systemd's tools.

But, I'm happy to include support for systemd.

Reading through the sample you've provided appears a bit incomplete/incorrect, so we can't include it as is. The service file should try to adhere to the init script as much as possible. You may want to look at the PostgreSQL service files for inspiration.

It's expected that:
 - the socket file be in the /run/postgresql directory
 - the mode of /run/postgresql 1755
 - the ownership of /run/postgresql be root:postgres
 - the log file (/var/log/pgbouncer/pgbouncer.log, I think) be owned pgbouncer:postgres
 - the log file (/var/log/pgbouncer/pgbouncer.log, I think) have mode 0640
 - the log file directory (/var/log/pgbouncer/, I think) have mode 0755
 - the log file directory (/var/log/pgbouncer/, I think) be owned pgbouncer:postgres

This is because the default installation should assume that all applications will connect through pgbouncer rather than directly to PostgreSQL. So, it needs to put the socket file in the default location Postgres would put it.

I think there's some limitations to systemd that won't allow us to avoid conflicts with the PostgreSQL service files, but you should ask somebody who knows more than me. Maybe chat with the guys on Freenode IRC #gentoo-proxy-maint.
Comment 3 Vasilis Lourdas 2020-10-11 06:15:19 UTC
Created attachment 664582 [details]

pgbouncer.service v.2
Comment 4 Vasilis Lourdas 2020-10-11 06:15:49 UTC
Created attachment 664585 [details]

Comment 5 Vasilis Lourdas 2020-10-13 12:18:33 UTC
Created attachment 665038 [details]
pgbouncer.service v.3

Having both service and socket file, the socket would be created, but the pgbouncer daemon would not listen on the tcp port, so you could only connect via the socket. Having just the service file, the daemon listens to the host interface and tcp port that you have configured in pgbouncer.ini and the socket file is also created under /run/postgresql. This works fine for me.