git: cac7f24191df - main - databases/pg_auto_failover-devel: new port: PG extension for automated failover and HA

From: Dave Cottlehuber <dch_at_FreeBSD.org>
Date: Sun, 22 Feb 2026 16:55:08 UTC
The branch main has been updated by dch:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cac7f24191df18d1cec7f52ad3e8097432330641

commit cac7f24191df18d1cec7f52ad3e8097432330641
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-devel: new port: PG extension for automated failover and HA
    
    WWW: https://pg-auto-failover.readthedocs.io
    PR: 292994
---
 databases/Makefile                                 |  1 +
 databases/pg_auto_failover-devel/Makefile          | 32 +++++++++
 databases/pg_auto_failover-devel/distinfo          |  3 +
 .../files/pg_auto_failover.in                      | 76 ++++++++++++++++++++++
 databases/pg_auto_failover-devel/pkg-descr         | 26 ++++++++
 databases/pg_auto_failover-devel/pkg-plist         | 15 +++++
 databases/pg_auto_failover/Makefile                |  2 +
 7 files changed, 155 insertions(+)

diff --git a/databases/Makefile b/databases/Makefile
index bdbca3e34739..fc8a621c1441 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -543,6 +543,7 @@
     SUBDIR += pgFormatter
     SUBDIR += pg_activity
     SUBDIR += pg_auto_failover
+    SUBDIR += pg_auto_failover-devel
     SUBDIR += pg_citus
     SUBDIR += pg_cron
     SUBDIR += pg_dirtyread
diff --git a/databases/pg_auto_failover-devel/Makefile b/databases/pg_auto_failover-devel/Makefile
new file mode 100644
index 000000000000..d8ebb2528785
--- /dev/null
+++ b/databases/pg_auto_failover-devel/Makefile
@@ -0,0 +1,32 @@
+PORTNAME=	pg_auto_failover
+DISTVERSION=	g20251117
+CATEGORIES=	databases
+PKGNAMEPREFIX=	postgresql${PGSQL_VER_NODOT}-
+PKGNAMESUFFIX=	-devel
+
+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=	18
+USES=		gmake pgsql:13-${__MAX_PGSQL}
+WANT_PGSQL=	contrib server
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	hapostgres
+GH_TAGNAME=	5f31d4f5ef322b339d67cfd79d773e11f9e30fb0
+
+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-devel/distinfo b/databases/pg_auto_failover-devel/distinfo
new file mode 100644
index 000000000000..57922de56911
--- /dev/null
+++ b/databases/pg_auto_failover-devel/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1770366586
+SHA256 (hapostgres-pg_auto_failover-g20251117-5f31d4f5ef322b339d67cfd79d773e11f9e30fb0_GH0.tar.gz) = d9aef136094c1f90ca39221155b95df04d7e209662b1a715740bfbe14cac5221
+SIZE (hapostgres-pg_auto_failover-g20251117-5f31d4f5ef322b339d67cfd79d773e11f9e30fb0_GH0.tar.gz) = 1142071
diff --git a/databases/pg_auto_failover-devel/files/pg_auto_failover.in b/databases/pg_auto_failover-devel/files/pg_auto_failover.in
new file mode 100644
index 000000000000..bfb500a58924
--- /dev/null
+++ b/databases/pg_auto_failover-devel/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-devel/pkg-descr b/databases/pg_auto_failover-devel/pkg-descr
new file mode 100644
index 000000000000..9760fa1411ab
--- /dev/null
+++ b/databases/pg_auto_failover-devel/pkg-descr
@@ -0,0 +1,26 @@
+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
+18.
+
+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
+
+This is the development version tracking the main branch.
diff --git a/databases/pg_auto_failover-devel/pkg-plist b/databases/pg_auto_failover-devel/pkg-plist
new file mode 100644
index 000000000000..aea7ca0763e3
--- /dev/null
+++ b/databases/pg_auto_failover-devel/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
diff --git a/databases/pg_auto_failover/Makefile b/databases/pg_auto_failover/Makefile
index 6f84a6023fa9..d6d48afad4ba 100644
--- a/databases/pg_auto_failover/Makefile
+++ b/databases/pg_auto_failover/Makefile
@@ -18,6 +18,8 @@ WANT_PGSQL=	contrib server
 USE_GITHUB=	yes
 GH_ACCOUNT=	hapostgres
 
+CONFLICTS=	postgresql*-pg_auto_failover*
+
 USE_RC_SUBR=	pg_auto_failover
 
 CONFLICTS=	postgresql*-pg_auto_failover*