Skip to content

Commit 8aa8066

Browse files
committed
Set the log level and get the probe port from pfconfig
1 parent a37f541 commit 8aa8066

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

conf/systemd/packetfence-pfudpproxy.service

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ After=packetfence-keepalived.service packetfence-base.target packetfence-config.
88
Type=notify
99
WatchdogSec=30s
1010
NotifyAccess=all
11-
# Fingerbank-collector health check port (default: 4723)
12-
#Environment=PFUDPPROXY_HEALTH_CHECK_PORT=4723
11+
Environment=LOG_LEVEL=info
1312
ExecStart=/usr/local/pf/sbin/pfudpproxy
1413
Restart=on-failure
1514
StartLimitBurst=3

go/cmd/pfudpproxy/config.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"os"
7-
"strconv"
86
"time"
97

108
"github.com/inverse-inc/go-utils/log"
@@ -43,12 +41,11 @@ type Backend struct {
4341
LastCheck time.Time
4442
}
4543

46-
// getHealthCheckPort returns the health check port from environment variable or default
47-
func getHealthCheckPort() int {
48-
if portStr := os.Getenv("PFUDPPROXY_HEALTH_CHECK_PORT"); portStr != "" {
49-
if port, err := strconv.Atoi(portStr); err == nil && port > 0 && port < 65536 {
50-
return port
51-
}
44+
// getHealthCheckPort returns the health check port from FingerbankSettingsCollector or default
45+
func getHealthCheckPort(ctx context.Context) int {
46+
collector := pfconfigdriver.GetType[pfconfigdriver.FingerbankSettingsCollector](ctx)
47+
if port, err := collector.Port.Int64(); err == nil && port > 0 && port < 65536 {
48+
return int(port)
5249
}
5350
return DefaultHealthCheckPort
5451
}
@@ -57,7 +54,7 @@ func getHealthCheckPort() int {
5754
func LoadConfig(ctx context.Context) (*ProxyConfig, error) {
5855
config := &ProxyConfig{
5956
Ports: []int{PortNetFlow, PortSFlow},
60-
HealthCheckPort: getHealthCheckPort(),
57+
HealthCheckPort: getHealthCheckPort(ctx),
6158
HealthCheckPath: DefaultHealthCheckPath,
6259
HealthCheckInterval: DefaultHealthCheckInterval,
6360
HealthCheckTimeout: DefaultHealthCheckTimeout,

0 commit comments

Comments
 (0)