pgbouncemgr/setup.py

68 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
"""
pgbouncemgr
===========
PostgreSQL has no support for a multi-primary HA setup. Instead, there is
always a single primary server, which can be used for reading and writing,
and one or more replicate servers, which can only be used for reading.
Updates on the primary server are streamed to the connected replica servers.
Therefore, when a client must connect to a PostgreSQL HA setup, it needs to
know what node to connect to (i.e. the currently active primary node).
Ideally, it has no knowledge about this, letting the client always connect
to the same endpoint.
This is where tools like haproxy and pgbouncer come in (possibly themselves
in an HA setup using automatic failover based on keepalived or one of its
friends). The client can connect to haproxy or bgbouncer, and those can be
configured to send the connection to the correct PostgreSQL node.
And this is where pgbouncemgr comes in. It actively monitors a PostgreSQL HA
cluster. Based on the monitoring data, it decides to what node clients must
connect and (re)configures pgbouncer to make that happen.
"""
import os
import re
from time import time
from setuptools import setup
def _get_version():
path = os.path.abspath(".")
pkginit = os.path.join(path, "pgbouncemgr", "__init__.py")
with open(pkginit, "r") as fh:
for line in fh.readlines():
m = re.match(r"^__version__\s*=\s*\"(.*)\"", line)
if (m is not None):
version = m.groups()[0]
return "%s.%d" % (version, time())
raise Exception("Unable to read version from %s" % pkginit)
setup(
name="pgbouncemgr",
version=_get_version(),
url="https://github.xs4all.net/XS4ALL/xs4all-pgbouncemgr",
license="BSD",
author="Maurice Makaay",
author_email="mmakaay1@xs4all.net",
description="Automatic (re)configuration of a pgbouncer server for a PostgreSQL HA cluster",
long_description=__doc__,
packages=[
"pgbouncemgr"
],
entry_points = {
'console_scripts': [
'pgbouncemgr=pgbouncemgr.manager:main']
},
data_files=[
("/etc/systemd/system", ["etc/pgbouncemgr.service"])
],
zip_safe=False,
include_package_data=True,
platforms="any",
test_suite="tests.suite"
)