git: 5be8c5775761 - main - databases/pg_auto_failover: new port: PG extension for automated failover and HA
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 22 Feb 2026 16:55:07 UTC
The branch main has been updated by dch:
URL: https://cgit.FreeBSD.org/ports/commit/?id=5be8c5775761808cd1cf3721958e0eb0830bc174
commit 5be8c5775761808cd1cf3721958e0eb0830bc174
Author: Pat Maddox <pat@patmaddox.com>
AuthorDate: 2026-02-22 16:51:43 +0000
Commit: Dave Cottlehuber <dch@FreeBSD.org>
CommitDate: 2026-02-22 16:52:01 +0000
databases/pg_auto_failover: new port: PG extension for automated failover and HA
WWW: https://pg-auto-failover.readthedocs.io
PR: 292990
---
databases/Makefile | 1 +
databases/pg_auto_failover/Makefile | 31 +++++++++
databases/pg_auto_failover/distinfo | 3 +
.../pg_auto_failover/files/pg_auto_failover.in | 76 ++++++++++++++++++++++
databases/pg_auto_failover/pkg-descr | 24 +++++++
databases/pg_auto_failover/pkg-plist | 15 +++++
6 files changed, 150 insertions(+)
diff --git a/databases/Makefile b/databases/Makefile
index ff71f23fd588..bdbca3e34739 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -542,6 +542,7 @@
SUBDIR += pg.el
SUBDIR += pgFormatter
SUBDIR += pg_activity
+ SUBDIR += pg_auto_failover
SUBDIR += pg_citus
SUBDIR += pg_cron
SUBDIR += pg_dirtyread
diff --git a/databases/pg_auto_failover/Makefile b/databases/pg_auto_failover/Makefile
new file mode 100644
index 000000000000..6f84a6023fa9
--- /dev/null
+++ b/databases/pg_auto_failover/Makefile
@@ -0,0 +1,31 @@
+PORTNAME= pg_auto_failover
+DISTVERSIONPREFIX= v
+DISTVERSION= 2.2
+CATEGORIES= databases
+PKGNAMEPREFIX= postgresql${PGSQL_VER_NODOT}-
+
+MAINTAINER= pat@patmaddox.com
+COMMENT= Postgres extension for automated failover and high-availability
+WWW= https://pg-auto-failover.readthedocs.io
+
+LICENSE= PostgreSQL
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+__MAX_PGSQL= 17
+USES= gmake pgsql:13-${__MAX_PGSQL}
+WANT_PGSQL= contrib server
+
+USE_GITHUB= yes
+GH_ACCOUNT= hapostgres
+
+USE_RC_SUBR= pg_auto_failover
+
+CONFLICTS= postgresql*-pg_auto_failover*
+
+.include <bsd.port.pre.mk>
+
+.if ${PGSQL_DEFAULT} > ${__MAX_PGSQL}
+PGSQL_VER= ${__MAX_PGSQL}
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/databases/pg_auto_failover/distinfo b/databases/pg_auto_failover/distinfo
new file mode 100644
index 000000000000..e08465d0e4d2
--- /dev/null
+++ b/databases/pg_auto_failover/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1761347036
+SHA256 (hapostgres-pg_auto_failover-v2.2_GH0.tar.gz) = 0f4018564e620592fcfb43d52ea2bc3ccba33bd824352fa9c7e55eb2ba0a4f6c
+SIZE (hapostgres-pg_auto_failover-v2.2_GH0.tar.gz) = 1140914
diff --git a/databases/pg_auto_failover/files/pg_auto_failover.in b/databases/pg_auto_failover/files/pg_auto_failover.in
new file mode 100644
index 000000000000..bfb500a58924
--- /dev/null
+++ b/databases/pg_auto_failover/files/pg_auto_failover.in
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+# PROVIDE: pg_auto_failover
+# REQUIRE: DAEMON mountlate
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# pg_auto_failover_enable (bool): Set to NO by default.
+# Set it to YES to enable pg_auto_failover.
+# pg_auto_failover_user (string): Set user to run pg_autoctl
+# Default is "postgres".
+# pg_auto_failover_pgdata (path): REQUIRED. Set the PGDATA directory.
+# This should point to your monitor or keeper data directory.
+# No default - must be explicitly configured.
+# pg_auto_failover_name (string): Optional friendly name for the node.
+# Useful for distinguishing nodes in monitor logs.
+# Default is "".
+# pg_auto_failover_hostname (string): Optional hostname or IP for node.
+# Used by other nodes to connect to this node.
+# Default is "" (pg_autoctl will auto-detect).
+# pg_auto_failover_pgport (int): PostgreSQL port number.
+# Default is "".
+
+. /etc/rc.subr
+
+name="pg_auto_failover"
+rcvar="${name}_enable"
+pidfile="/var/run/${name}.pid"
+logfile="/var/log/${name}.log"
+
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/pg_autoctl"
+start_cmd="${name}_start"
+
+load_rc_config ${name}
+: ${pg_auto_failover_enable:=no}
+: ${pg_auto_failover_user:=postgres}
+: ${pg_auto_failover_name:=""}
+: ${pg_auto_failover_hostname:=""}
+: ${pg_auto_failover_pgport:=""}
+
+start_precmd=pg_auto_failover_startprecmd
+
+pg_auto_failover_startprecmd() {
+ if [ -z "${pg_auto_failover_pgdata}" ]; then
+ err 1 "pg_auto_failover_pgdata is not set"
+ fi
+ if checkyesno postgresql_enable 2>/dev/null; then
+ err 1 "postgresql_enable must be NO when using pg_auto_failover (pg_autoctl manages PostgreSQL)"
+ fi
+}
+
+pg_auto_failover_start() {
+ local args
+ args="--pgdata ${pg_auto_failover_pgdata}"
+
+ if [ -n "${pg_auto_failover_pgport}" ]; then
+ args="${args} --pgport ${pg_auto_failover_pgport}"
+ fi
+ if [ -n "${pg_auto_failover_name}" ]; then
+ args="${args} --name ${pg_auto_failover_name}"
+ fi
+ if [ -n "${pg_auto_failover_hostname}" ]; then
+ args="${args} --hostname ${pg_auto_failover_hostname}"
+ fi
+
+ ${command} -t ${name} \
+ -p ${pidfile} \
+ -f -H -o ${logfile} \
+ -u ${pg_auto_failover_user} \
+ ${procname} run ${args}
+}
+
+run_rc_command "$1"
diff --git a/databases/pg_auto_failover/pkg-descr b/databases/pg_auto_failover/pkg-descr
new file mode 100644
index 000000000000..971b7e1247a1
--- /dev/null
+++ b/databases/pg_auto_failover/pkg-descr
@@ -0,0 +1,24 @@
+pg_auto_failover is an extension and service for PostgreSQL that
+monitors and manages automated failover for a Postgres cluster. It is
+optimized for simplicity and correctness and supports Postgres 13 to
+17.
+
+pg_auto_failover supports several Postgres architectures and
+implements a safe automated failover for your Postgres service. It is
+possible to get started with only two data nodes which will be given
+the roles of primary and secondary by the monitor.
+
+The pg_auto_failover Monitor implements a state machine and relies on
+in-core PostgreSQL facilities to deliver HA. For example, when the
+secondary node is detected to be unavailable, or when its lag is too
+much, then the Monitor removes it from the synchronous_standby_names
+setting on the primary node. Until the secondary is back to being
+monitored healthy, failover and switchover operations are not allowed,
+preventing data loss.
+
+pg_auto_failover consists of the following parts:
+
+- a PostgreSQL extension named pgautofailover
+- a PostgreSQL service to operate the pg_auto_failover monitor
+- a pg_auto_failover keeper to operate your PostgreSQL instances, see
+ pg_autoctl run
diff --git a/databases/pg_auto_failover/pkg-plist b/databases/pg_auto_failover/pkg-plist
new file mode 100644
index 000000000000..aea7ca0763e3
--- /dev/null
+++ b/databases/pg_auto_failover/pkg-plist
@@ -0,0 +1,15 @@
+bin/pg_autoctl
+lib/postgresql/pgautofailover.so
+share/postgresql/extension/pgautofailover--1.0--1.1.sql
+share/postgresql/extension/pgautofailover--1.0.sql
+share/postgresql/extension/pgautofailover--1.1--1.2.sql
+share/postgresql/extension/pgautofailover--1.2--1.3.sql
+share/postgresql/extension/pgautofailover--1.3--1.4.sql
+share/postgresql/extension/pgautofailover--1.4--1.5.sql
+share/postgresql/extension/pgautofailover--1.5--1.6.sql
+share/postgresql/extension/pgautofailover--1.6--2.0.sql
+share/postgresql/extension/pgautofailover--2.0--2.1.sql
+share/postgresql/extension/pgautofailover--2.1--2.2.sql
+share/postgresql/extension/pgautofailover--2.2--dummy.sql
+share/postgresql/extension/pgautofailover--2.2.sql
+share/postgresql/extension/pgautofailover.control