feat: add MONITOR_PORT env var and monitorPort config field
- Added MonitorPort field to Config struct (TODO 5.1) - Config loads from MONITOR_PORT or HF_MONITOR_PORT env vars - Added to Dockerfile env defaults - Updated config.example.json - Merge function handles monitorPort from file config Prepares Monitor for local plugin communication bridge (TODO 5.1, 5.2)
This commit is contained in:
@@ -15,6 +15,7 @@ ENV HF_MONITER_BACKEND_URL=https://monitor.hangman-lab.top \
|
|||||||
HF_MONITER_API_KEY= \
|
HF_MONITER_API_KEY= \
|
||||||
HF_MONITER_REPORT_INTERVAL=30 \
|
HF_MONITER_REPORT_INTERVAL=30 \
|
||||||
HF_MONITER_LOG_LEVEL=info \
|
HF_MONITER_LOG_LEVEL=info \
|
||||||
HF_MONITER_ROOTFS=/host
|
HF_MONITER_ROOTFS=/host \
|
||||||
|
MONITOR_PORT=0
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/harborforge-monitor"]
|
ENTRYPOINT ["/usr/local/bin/harborforge-monitor"]
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
"apiKey": "replace-with-server-api-key",
|
"apiKey": "replace-with-server-api-key",
|
||||||
"reportIntervalSec": 30,
|
"reportIntervalSec": 30,
|
||||||
"logLevel": "info",
|
"logLevel": "info",
|
||||||
"rootFs": "/host"
|
"rootFs": "/host",
|
||||||
|
"monitorPort": 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type Config struct {
|
|||||||
ReportIntervalSec int `json:"reportIntervalSec"`
|
ReportIntervalSec int `json:"reportIntervalSec"`
|
||||||
LogLevel string `json:"logLevel"`
|
LogLevel string `json:"logLevel"`
|
||||||
RootFS string `json:"rootFs"`
|
RootFS string `json:"rootFs"`
|
||||||
|
MonitorPort int `json:"monitorPort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load(path string) (Config, error) {
|
func Load(path string) (Config, error) {
|
||||||
@@ -43,6 +44,7 @@ func Load(path string) (Config, error) {
|
|||||||
cfg.ReportIntervalSec = getenvIntAny([]string{"HF_MONITER_REPORT_INTERVAL", "HF_MONITOR_REPORT_INTERVAL"}, cfg.ReportIntervalSec)
|
cfg.ReportIntervalSec = getenvIntAny([]string{"HF_MONITER_REPORT_INTERVAL", "HF_MONITOR_REPORT_INTERVAL"}, cfg.ReportIntervalSec)
|
||||||
cfg.LogLevel = getenvAny([]string{"HF_MONITER_LOG_LEVEL", "HF_MONITOR_LOG_LEVEL"}, cfg.LogLevel)
|
cfg.LogLevel = getenvAny([]string{"HF_MONITER_LOG_LEVEL", "HF_MONITOR_LOG_LEVEL"}, cfg.LogLevel)
|
||||||
cfg.RootFS = getenvAny([]string{"HF_MONITER_ROOTFS", "HF_MONITOR_ROOTFS"}, cfg.RootFS)
|
cfg.RootFS = getenvAny([]string{"HF_MONITER_ROOTFS", "HF_MONITOR_ROOTFS"}, cfg.RootFS)
|
||||||
|
cfg.MonitorPort = getenvIntAny([]string{"MONITOR_PORT", "HF_MONITOR_PORT"}, cfg.MonitorPort)
|
||||||
|
|
||||||
if cfg.BackendURL == "" {
|
if cfg.BackendURL == "" {
|
||||||
return cfg, fmt.Errorf("backendUrl is required")
|
return cfg, fmt.Errorf("backendUrl is required")
|
||||||
@@ -88,6 +90,9 @@ func merge(dst *Config, src Config) {
|
|||||||
if src.RootFS != "" {
|
if src.RootFS != "" {
|
||||||
dst.RootFS = src.RootFS
|
dst.RootFS = src.RootFS
|
||||||
}
|
}
|
||||||
|
if src.MonitorPort > 0 {
|
||||||
|
dst.MonitorPort = src.MonitorPort
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getenvAny(keys []string, fallback string) string {
|
func getenvAny(keys []string, fallback string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user