From 51e2f3de7e85efe55fc33b02eb30ddc68eb083b4 Mon Sep 17 00:00:00 2001 From: cclare Date: Wed, 2 Apr 2025 10:53:34 -0400 Subject: [PATCH 1/2] Add apply functions to HAProxy frontend --- .../local/pkg/RESTAPI/Models/HAProxyFrontend.inc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc index 90357d6bb..3910ac726 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc @@ -180,4 +180,18 @@ class HAProxyFrontend extends Model { parent::__construct($id, $parent_id, $data, ...$options); } + + /** + * Ensures haproxy is marked as dirty before applying. + */ + public function pre_apply(): void { + touch('/var/run/haproxy.conf.dirty'); + } + + /** + * Applies changes to the HAProxy configuration. + */ + public function apply(): void { + (new HAProxyApplyDispatcher(async: $this->async))->spawn_process(); + } } From e61a307c650554d2c6af583e2d7602c5addf5a9f Mon Sep 17 00:00:00 2001 From: cclare Date: Wed, 2 Apr 2025 11:54:08 -0400 Subject: [PATCH 2/2] Use HAProxyApplyDispatcher in HAProxyFrontend --- .../files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc index 3910ac726..eb36a9803 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyFrontend.inc @@ -3,6 +3,7 @@ namespace RESTAPI\Models; use RESTAPI\Core\Model; +use RESTAPI\Dispatchers\HAProxyApplyDispatcher; use RESTAPI\Fields\Base64Field; use RESTAPI\Fields\BooleanField; use RESTAPI\Fields\ForeignModelField;